- 
                Notifications
    
You must be signed in to change notification settings  - Fork 22
 
Add the possibility to use the Veros ocean model as the ocean component in ClimaOcean #602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            simone-silvestri
  wants to merge
  262
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
ss/adapt-veros
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 245 commits
      Commits
    
    
            Show all changes
          
          
            262 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      a130e73
              
                correct dates
              
              
                simone-silvestri c90b7f9
              
                Merge remote-tracking branch 'origin/main' into ss/metadata-for-every…
              
              
                simone-silvestri 08b377f
              
                syntax
              
              
                simone-silvestri 2eb5556
              
                Merge remote-tracking branch 'origin/main' into ss/metadata-for-every…
              
              
                simone-silvestri ba4bce0
              
                more updates
              
              
                simone-silvestri 68dfdb0
              
                all this should work?
              
              
                simone-silvestri f212e88
              
                clear comments
              
              
                simone-silvestri 1a68d4e
              
                vestigial code
              
              
                simone-silvestri c318e54
              
                works
              
              
                simone-silvestri 79b5935
              
                veeery much simplified
              
              
                simone-silvestri 91e1169
              
                this part is already done
              
              
                simone-silvestri b6fb198
              
                back to working
              
              
                simone-silvestri e81bdfb
              
                works
              
              
                simone-silvestri afbd1cc
              
                improve show method
              
              
                simone-silvestri 8599314
              
                change names
              
              
                simone-silvestri bb24633
              
                go ahead
              
              
                simone-silvestri 4f05dbb
              
                fix it
              
              
                simone-silvestri fe6dc72
              
                this should work
              
              
                simone-silvestri 787ebc9
              
                add a new constructor
              
              
                simone-silvestri 7c519a1
              
                set with ECCOMetadatum
              
              
                simone-silvestri 78a53cd
              
                some changes
              
              
                simone-silvestri 1e71d67
              
                improvement to UI
              
              
                simone-silvestri 4f7fdb2
              
                change examples
              
              
                simone-silvestri 58662d2
              
                we don't need this
              
              
                simone-silvestri 22c8d08
              
                chnages
              
              
                simone-silvestri 79f37eb
              
                export ui functions
              
              
                simone-silvestri a98669f
              
                last date
              
              
                simone-silvestri 5405ef3
              
                vestigial dates
              
              
                simone-silvestri b2ff520
              
                change docstrings
              
              
                simone-silvestri 992b4d7
              
                better like this
              
              
                simone-silvestri e65b0ea
              
                add native date range
              
              
                simone-silvestri e7a0039
              
                Merge branch 'main' into ss/distinguish-constructor
              
              
                simone-silvestri 40a9f24
              
                change the url
              
              
                simone-silvestri 58d5c11
              
                fix tests
              
              
                simone-silvestri 4fc2394
              
                fixing the tests
              
              
                simone-silvestri 385a44a
              
                fix tests
              
              
                simone-silvestri 54e5838
              
                it's six dates not 5
              
              
                simone-silvestri 925981d
              
                Merge branch 'main' into ss/distinguish-constructor
              
              
                simone-silvestri 62c2f46
              
                Merge branch 'ss/distinguish-constructor' into ss/multi-year-JRA55
              
              
                simone-silvestri fb35d78
              
                this works
              
              
                simone-silvestri 65ca9ba
              
                this works
              
              
                simone-silvestri 18504c5
              
                this should work
              
              
                simone-silvestri f35345c
              
                done
              
              
                simone-silvestri 97c91fd
              
                Merge branch 'main' into ss/distinguish-constructor
              
              
                navidcy 182cbfb
              
                use directory over folder; fix some docstrings
              
              
                navidcy a23c423
              
                Merge branch 'main' into ss/distinguish-constructor
              
              
                simone-silvestri f42a187
              
                add an ECCOMetadatum
              
              
                simone-silvestri 0a6dd9f
              
                Merge branch 'ss/distinguish-constructor' of github.com:CliMA/ClimaOc…
              
              
                simone-silvestri 790b5e6
              
                spacing
              
              
                simone-silvestri 1649353
              
                add a top level constant
              
              
                simone-silvestri 739bc46
              
                correct directory
              
              
                simone-silvestri 6ef9d7c
              
                add a default dowbload
              
              
                simone-silvestri 58c38c7
              
                Merge branch 'ss/distinguish-constructor' into ss/multi-year-JRA55
              
              
                simone-silvestri 4e53f82
              
                almost there
              
              
                simone-silvestri 29d15c8
              
                Merge branch 'main' into ss/multi-year-JRA55
              
              
                simone-silvestri 418fa99
              
                revert test ecco
              
              
                simone-silvestri f8cd74b
              
                Merge branch 'ss/multi-year-JRA55' of github.com:CliMA/ClimaOcean.jl …
              
              
                simone-silvestri 4761081
              
                Merge branch 'main' into ss/multi-year-JRA55
              
              
                simone-silvestri 93c6b6f
              
                bugfix
              
              
                simone-silvestri 0293afd
              
                Merge branch 'ss/multi-year-JRA55' of github.com:CliMA/ClimaOcean.jl …
              
              
                simone-silvestri cffb7e1
              
                Merge remote-tracking branch 'origin/main' into ss/multi-year-JRA55
              
              
                simone-silvestri 1febc0e
              
                Merge remote-tracking branch 'origin/main' into ss/multi-year-JRA55
              
              
                simone-silvestri ce7cbd3
              
                start changes
              
              
                simone-silvestri fbfe5ce
              
                this should work
              
              
                simone-silvestri 46940e7
              
                bugfix
              
              
                simone-silvestri 473dbd7
              
                some bugfixing
              
              
                simone-silvestri 3ccc9f7
              
                this works
              
              
                simone-silvestri a35bf04
              
                this works!
              
              
                simone-silvestri 68b3ff3
              
                add regularization
              
              
                simone-silvestri 5f53219
              
                bugfix
              
              
                simone-silvestri 9209bbf
              
                add sea-ice ocean stress
              
              
                simone-silvestri 62b4629
              
                Merge branch 'main' into ss/multi-year-JRA55
              
              
                simone-silvestri 4d963ea
              
                fix tests
              
              
                simone-silvestri 52c91d9
              
                Merge branch 'ss/multi-year-JRA55' of github.com:CliMA/ClimaOcean.jl …
              
              
                simone-silvestri 1ee41af
              
                bugfix
              
              
                simone-silvestri 1d58772
              
                Update JRA55_field_time_series.jl
              
              
                simone-silvestri 0c020d0
              
                Update JRA55_field_time_series.jl
              
              
                simone-silvestri bafe3c7
              
                simplify
              
              
                simone-silvestri 350b657
              
                add the inmemory stuff
              
              
                simone-silvestri 4a49b40
              
                start with this
              
              
                simone-silvestri fea1854
              
                default to inmemory
              
              
                simone-silvestri 4441567
              
                Merge remote-tracking branch 'origin/ss/multi-year-JRA55' into ss/omi…
              
              
                simone-silvestri 7c4aa61
              
                go!
              
              
                simone-silvestri 24f7d93
              
                add a failsafe + a test
              
              
                simone-silvestri d231995
              
                some cleanup
              
              
                simone-silvestri ca1980c
              
                better to write last
              
              
                simone-silvestri f448eeb
              
                Merge remote-tracking branch 'origin/ss/multi-year-JRA55' into ss/omi…
              
              
                simone-silvestri fed209b
              
                Merge branch 'main' into ss/sea-ice-momentum-stress
              
              
                simone-silvestri aeedd2f
              
                last index
              
              
                simone-silvestri f954c69
              
                Merge branch 'ss/sea-ice-momentum-stress' of github.com:CliMA/ClimaOc…
              
              
                simone-silvestri ddee7f0
              
                add this
              
              
                simone-silvestri daeb12f
              
                add a clock
              
              
                simone-silvestri 629d582
              
                add the arctic
              
              
                simone-silvestri 54165a0
              
                Merge branch 'ss/sea-ice-momentum-stress' into ss/omip-prototype
              
              
                simone-silvestri 35fe01d
              
                try it out
              
              
                simone-silvestri 5548a99
              
                correct dates
              
              
                simone-silvestri dfb8590
              
                Update experiments/omip_prototype/quarter_degree_omip.jl
              
              
                simone-silvestri a049dc1
              
                Update experiments/omip_prototype/quarter_degree_omip.jl
              
              
                simone-silvestri d1e6faf
              
                add stuff
              
              
                simone-silvestri 7186256
              
                Merge branch 'main' into ss/omip-prototype
              
              
                simone-silvestri a6d758d
              
                going sixth degree
              
              
                simone-silvestri 0b8624e
              
                Merge branch 'ss/omip-prototype' of github.com:CliMA/ClimaOcean.jl in…
              
              
                simone-silvestri f18a772
              
                some changes
              
              
                simone-silvestri 6679bbd
              
                synchronize the clocks for the moment
              
              
                simone-silvestri 50a7226
              
                Merge branch 'main' into ss/omip-prototype
              
              
                simone-silvestri 7975dd4
              
                Update test_jra55.jl
              
              
                simone-silvestri 77e440b
              
                bugfix
              
              
                simone-silvestri 5e3c729
              
                Merge branch 'ss/omip-prototype' of github.com:CliMA/ClimaOcean.jl in…
              
              
                simone-silvestri b05fb83
              
                improve it quickly for now
              
              
                simone-silvestri 501b3fa
              
                continue
              
              
                simone-silvestri f258e29
              
                Merge branch 'ss/omip-prototype' of github.com:CliMA/ClimaOcean.jl in…
              
              
                simone-silvestri 5751899
              
                another try...
              
              
                simone-silvestri af67adc
              
                bugfix for the salt flux
              
              
                simone-silvestri d008026
              
                Merge remote-tracking branch 'origin/main' into ss/omip-prototype
              
              
                simone-silvestri 83f97e9
              
                try it out
              
              
                simone-silvestri 03e7f19
              
                correction
              
              
                simone-silvestri 1e02dd9
              
                Merge remote-tracking branch 'origin/main' into ss/omip-prototype
              
              
                simone-silvestri 1eedc44
              
                correct
              
              
                simone-silvestri 202212c
              
                update
              
              
                simone-silvestri efa566c
              
                Merge remote-tracking branch 'origin/main' into ss/omip-prototype
              
              
                simone-silvestri 0c8d8b1
              
                go for it
              
              
                simone-silvestri 0f04d0f
              
                Update src/SeaIceSimulations.jl
              
              
                simone-silvestri e28b9a4
              
                Update SeaIceSimulations.jl
              
              
                simone-silvestri 0e1d4ca
              
                Merge branch 'ss/default-sea-ice' into ss/omip-prototype
              
              
                simone-silvestri 2eeed4c
              
                some.. salinity
              
              
                simone-silvestri b27ac12
              
                Merge branch 'main' into ss/omip-prototype
              
              
                simone-silvestri 4d09283
              
                Merge branch 'main' into ss/omip-prototype
              
              
                simone-silvestri 1507936
              
                Merge remote-tracking branch 'origin/main' into ss/omip-prototype
              
              
                simone-silvestri 702fe64
              
                update sea ice simulation
              
              
                simone-silvestri 9664584
              
                try like this for the moment and let it go
              
              
                simone-silvestri 8392922
              
                Merge remote-tracking branch 'origin/main' into ss/omip-prototype
              
              
                simone-silvestri d28b611
              
                added project
              
              
                simone-silvestri 4b763ee
              
                Merge branch 'ss/omip-prototype' of github.com:CliMA/ClimaOcean.jl in…
              
              
                simone-silvestri c306b0f
              
                retry like this
              
              
                simone-silvestri 83331f8
              
                Merge branch 'ss/omip-prototype' of github.com:CliMA/ClimaOcean.jl in…
              
              
                simone-silvestri 4857647
              
                hmmm this was explicit
              
              
                simone-silvestri 668bc53
              
                use a fixed dt
              
              
                simone-silvestri dcce9e2
              
                update to new syntax
              
              
                simone-silvestri d5288c1
              
                go like this
              
              
                simone-silvestri 1322148
              
                add a one-degree to test it out
              
              
                simone-silvestri 2490da2
              
                Update one_degree_simulation.jl
              
              
                simone-silvestri c411c71
              
                Update one_degree_simulation.jl
              
              
                simone-silvestri f762205
              
                try without implicit solver
              
              
                simone-silvestri 759c1ac
              
                Update Project.toml
              
              
                simone-silvestri 01e9f05
              
                Update near_global_ocean_simulation.jl
              
              
                simone-silvestri e48a2b5
              
                Update one_degree_simulation.jl
              
              
                simone-silvestri 0765874
              
                changes
              
              
                simone-silvestri 808e6c9
              
                try it in both
              
              
                simone-silvestri 88bd4e8
              
                Merge branch 'ss/adapt-to-new-oceananigans' into ss/zstar
              
              
                simone-silvestri 7cacb1d
              
                adding the correct zstar branch
              
              
                simone-silvestri 7cb8d6b
              
                added CUDA
              
              
                simone-silvestri 469883a
              
                Update pipeline.yml
              
              
                simone-silvestri 86d0bce
              
                revert CUDA
              
              
                simone-silvestri 509d6b4
              
                enforce using a specific branch
              
              
                navidcy 308c9e3
              
                Delete Manifest.toml
              
              
                navidcy 06d895c
              
                Update Project.toml
              
              
                navidcy 6397010
              
                enforce using Oceananigans#ss/fix-zstar-bc
              
              
                navidcy ea59ebb
              
                drop geebrish
              
              
                navidcy 352a3ef
              
                enforce using Oceananigans#ss/fix-zstar-bc
              
              
                navidcy 2beac0e
              
                use julia v1.10.10
              
              
                navidcy ea86989
              
                precompile again
              
              
                navidcy 89af369
              
                use julia v1.10.10
              
              
                navidcy 9e2482b
              
                first oceananigans; then develop
              
              
                navidcy 9affa64
              
                add CUDA
              
              
                navidcy 7717533
              
                using CUDA + record from Makie not CUDA
              
              
                navidcy 6e0be09
              
                Update one_degree_simulation.jl
              
              
                simone-silvestri 4488c2e
              
                some changes
              
              
                simone-silvestri 26fde07
              
                Merge branch 'ss/zstar' of github.com:CliMA/ClimaOcean.jl into ss/zstar
              
              
                simone-silvestri a436bed
              
                increase a bit
              
              
                simone-silvestri 5746652
              
                add more stuff
              
              
                simone-silvestri 5127f05
              
                improvements
              
              
                simone-silvestri 1037980
              
                improve
              
              
                simone-silvestri 71c82f5
              
                add an equatorial single column
              
              
                simone-silvestri bc33d07
              
                possibly remove a bug?
              
              
                simone-silvestri ed0d210
              
                Update atmosphere_sea_ice_fluxes.jl
              
              
                simone-silvestri 5b5b747
              
                Update atmosphere_sea_ice_fluxes.jl
              
              
                simone-silvestri 28d3e4e
              
                adding the correct Manifest
              
              
                simone-silvestri 00a2933
              
                Merge branch 'ss/zstar' of github.com:CliMA/ClimaOcean.jl into ss/zstar
              
              
                simone-silvestri d7ef440
              
                update
              
              
                simone-silvestri b0d1fd3
              
                Merge branch 'main' into ss/zstar
              
              
                navidcy 860ff09
              
                Merge branch 'main' into ss/zstar
              
              
                simone-silvestri 5637600
              
                Merge branch 'ss/zstar' of github.com:CliMA/ClimaOcean.jl into ss/zstar
              
              
                simone-silvestri b3ab48b
              
                remove equatorial single column
              
              
                simone-silvestri d1c7450
              
                remove manifest
              
              
                simone-silvestri a1ede1f
              
                revert
              
              
                simone-silvestri 4015bf4
              
                token
              
              
                simone-silvestri 970ffeb
              
                Revert "token"
              
              
                simone-silvestri 4b4f64e
              
                Merge remote-tracking branch 'origin/ss/zstar' into ss/omip-prototype
              
              
                simone-silvestri e6ff0d4
              
                changed JRA55
              
              
                simone-silvestri ef45d0c
              
                added Project
              
              
                simone-silvestri d96c32b
              
                merged
              
              
                simone-silvestri ea3ee12
              
                bugfix
              
              
                simone-silvestri 9165bd2
              
                Merge branch 'ss/omip-prototype' of github.com:CliMA/ClimaOcean.jl in…
              
              
                simone-silvestri add5526
              
                this should fix it
              
              
                simone-silvestri 35e2df6
              
                Merge remote-tracking branch 'origin/main' into ss/omip-prototype
              
              
                simone-silvestri 92fda28
              
                change sea ice
              
              
                simone-silvestri ec70ca0
              
                Merge remote-tracking branch 'origin/main' into ss/omip-prototype
              
              
                simone-silvestri 469bcb1
              
                consolidate sea ice temperature
              
              
                simone-silvestri 736ac4c
              
                adding the manifest
              
              
                simone-silvestri 6db860a
              
                adding Manifest
              
              
                simone-silvestri 5e0997c
              
                comment out for now
              
              
                simone-silvestri 049dacd
              
                go for it
              
              
                simone-silvestri cf22586
              
                Merge branch 'ss/omip-prototype' of github.com:CliMA/ClimaOcean.jl in…
              
              
                simone-silvestri 17a2250
              
                improve
              
              
                simone-silvestri d024542
              
                Merge remote-tracking branch 'origin/main' into ss/omip-prototype
              
              
                simone-silvestri 7d6ce58
              
                improving the performance
              
              
                simone-silvestri 5e66a54
              
                speed up
              
              
                simone-silvestri 9063e3e
              
                recorrect Oceananigans
              
              
                simone-silvestri 4fb3526
              
                Merge branch 'main' into ss/omip-prototype
              
              
                simone-silvestri e7845a5
              
                new Manifest
              
              
                simone-silvestri fca5484
              
                do not add Oceananigans
              
              
                simone-silvestri 09d22a3
              
                Update make.jl
              
              
                simone-silvestri 3885668
              
                one-degree-ompi for calibration
              
              
                simone-silvestri 8bbc3b8
              
                Merge branch 'ss/omip-prototype' of github.com:CliMA/ClimaOcean.jl in…
              
              
                simone-silvestri 988ec77
              
                update one degree
              
              
                simone-silvestri 3419022
              
                use the correct value
              
              
                simone-silvestri b1430e2
              
                remove this for the moment
              
              
                simone-silvestri abced34
              
                Merge branch 'ss/omip-prototype' of github.com:CliMA/ClimaOcean.jl in…
              
              
                simone-silvestri 78de681
              
                start with adapting
              
              
                simone-silvestri 3772b2c
              
                fill it in
              
              
                simone-silvestri b5befcd
              
                remove manifest
              
              
                simone-silvestri 1a40428
              
                remove vestigial code
              
              
                simone-silvestri 0876b41
              
                add a simulation
              
              
                simone-silvestri dc79dc0
              
                add an OceananigansSimulation
              
              
                simone-silvestri adb8393
              
                ok this works
              
              
                simone-silvestri ff57090
              
                add a forced simulation
              
              
                simone-silvestri 2460b14
              
                update
              
              
                simone-silvestri b74450f
              
                coupled
              
              
                simone-silvestri 7792990
              
                some corrections
              
              
                simone-silvestri bf23df7
              
                back to previous stuff
              
              
                simone-silvestri 5b03a33
              
                add veros
              
              
                simone-silvestri 5843397
              
                add the veros experiment
              
              
                simone-silvestri cc6ca11
              
                dt mom not dt tracer
              
              
                simone-silvestri 267d985
              
                Apply suggestion from @glwagner
              
              
                simone-silvestri 8602684
              
                Apply suggestion from @glwagner
              
              
                simone-silvestri d45906b
              
                Update assemble_net_fluxes.jl
              
              
                simone-silvestri 29c70ca
              
                Rename fill_up_net_fluxes! to fill_net_fluxes!
              
              
                simone-silvestri c7ee9ad
              
                Update ext/ClimaOceanPythonCallExt/ClimaOceanPythonCallExt.jl
              
              
                simone-silvestri c7dbcb0
              
                overload the set! function
              
              
                simone-silvestri ac8d821
              
                bugfix
              
              
                simone-silvestri 2d0c16b
              
                bugfix
              
              
                simone-silvestri 2debe0e
              
                bugfix
              
              
                simone-silvestri b3c6c46
              
                fixed it
              
              
                simone-silvestri 8cfb21d
              
                let's go
              
              
                simone-silvestri 88e937c
              
                add visualization
              
              
                simone-silvestri 507e81c
              
                Merge branch 'main' into ss/adapt-veros
              
              
                simone-silvestri 3d99939
              
                Merge branch 'main' into ss/adapt-veros
              
              
                simone-silvestri da45c7e
              
                Merge branch 'main' into ss/adapt-veros
              
              
                simone-silvestri 8aa6b13
              
                Merge branch 'main' into ss/adapt-veros
              
              
                simone-silvestri 62a3cc8
              
                Update TODO comment for fluxes BC in veros
              
              
                simone-silvestri File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| 
     | 
||
| [pip.deps] | ||
| copernicusmarine = ">=2.0.0" | ||
| xarray = ">=2024.7.0" | ||
| numpy = ">=2.0.0" | ||
| jax = ">=0.6" | ||
| copernicusmarine = ">=2.0.0" | ||
| numpy = "==2.3.1" | ||
| tensorflow = ">=2.17" | ||
| veros = "" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| using ClimaOcean | ||
| using PythonCall | ||
| using Oceananigans | ||
| using Printf | ||
| 
     | 
||
| ##### | ||
| ##### A Prognostic Python Ocean (Veros) Simulation | ||
| ##### | ||
| 
     | 
||
| # We import the Veros 4 degree ocean simulation setup, which consists of a near-global ocean | ||
| # with a uniform resolution of 4 degrees in both latitude and longitude and a latitude range spanning | ||
| # from 80S to 80N. The setup is defined in the `veros.setups.global_4deg` module. | ||
| 
     | 
||
| # Before importing the setup, we need to ensure that the Veros module is loaded | ||
| # and that every output is removed to avoid conflicts. | ||
| 
     | 
||
| VerosModule = Base.get_extension(ClimaOcean, :ClimaOceanPythonCallExt) | ||
| VerosModule.remove_outputs(:global_4deg) | ||
| 
     | 
||
| # Actually loading and instantiating the Veros setup in the variable `ocean`. | ||
| # This setup uses by default a different time-step for tracers and momentum, | ||
| # so we set it to the same value (1800 seconds) for both. | ||
| 
     | 
||
| ocean = VerosModule.VerosOceanSimulation("global_4deg", :GlobalFourDegreeSetup) | ||
| 
     | 
||
| VerosModule.veros_settings_set!(ocean, "dt_tracer", 1800.0) | ||
| VerosModule.veros_settings_set!(ocean, "dt_mom", 1800.0) | ||
| 
     | 
||
| ##### | ||
| ##### A Prescribed Atmosphere (JRA55) | ||
| ##### | ||
| 
     | 
||
| atmos = JRA55PrescribedAtmosphere(; backend = JRA55NetCDFBackend(10)) | ||
| 
     | 
||
| ##### | ||
| ##### An ice-free ocean forced by a prescribed atmosphere | ||
| ##### | ||
| 
     | 
||
| radiation = Radiation() | ||
| coupled_model = OceanSeaIceModel(ocean, nothing; atmosphere=atmos, radiation) | ||
| simulation = Simulation(coupled_model; Δt = 1800, stop_iteration = 100000) | ||
| 
     | 
||
| ##### | ||
| ##### A simple progress callback | ||
| ##### | ||
| 
     | 
||
| # We set up a progress callback that will print the current time, iteration, and maximum velocities | ||
| # at every 5 iterations. It also collects the surface velocity fields and the net fluxes | ||
| # into the arrays `s`, `tx`, and `ty` for later visualization. | ||
| 
     | 
||
| wall_time = Ref(time_ns()) | ||
| 
     | 
||
| s = [] | ||
| tx = [] | ||
| ty = [] | ||
| 
     | 
||
| us = coupled_model.interfaces.exchanger.exchange_ocean_state.u | ||
| vs = coupled_model.interfaces.exchanger.exchange_ocean_state.v | ||
| 
     | 
||
| stmp = Field(sqrt(us^2 + vs^2)) | ||
| 
     | 
||
| function progress(sim) | ||
| ocean = sim.model.ocean | ||
| umax = maximum(PyArray(ocean.setup.state.variables.u)) | ||
| vmax = maximum(PyArray(ocean.setup.state.variables.v)) | ||
| wmax = maximum(PyArray(ocean.setup.state.variables.w)) | ||
| 
     | 
||
| step_time = 1e-9 * (time_ns() - wall_time[]) | ||
| 
     | 
||
| msg1 = @sprintf("time: %s, iteration: %d, Δt: %s, ", prettytime(sim), iteration(sim), prettytime(sim.Δt)) | ||
| msg5 = @sprintf("maximum(u): (%.2f, %.2f, %.2f) m/s, ", umax, vmax, wmax) | ||
| msg6 = @sprintf("wall time: %s \n", prettytime(step_time)) | ||
| 
     | 
||
| @info msg1 * msg5 * msg6 | ||
| 
     | 
||
| wall_time[] = time_ns() | ||
| 
     | 
||
| compute!(stmp) | ||
| push!(s, deepcopy(interior(stmp, :, :, 1))) | ||
| push!(tx, deepcopy(interior(coupled_model.interfaces.net_fluxes.ocean_surface.u, :, :, 1) .* 1020)) | ||
| push!(ty, deepcopy(interior(coupled_model.interfaces.net_fluxes.ocean_surface.v, :, :, 1) .* 1020)) | ||
| 
     | 
||
| return nothing | ||
| end | ||
| 
     | 
||
| add_callback!(simulation, progress, IterationInterval(5)) | ||
| 
     | 
||
| ##### | ||
| ##### Let's go!! | ||
| ##### | ||
| 
     | 
||
| run!(simulation) | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| module ClimaOceanPythonCallExt | ||
| 
     | 
||
| using ClimaOcean | ||
| using CondaPkg | ||
| using PythonCall | ||
| using Oceananigans | ||
| using Oceananigans.DistributedComputations: @root | ||
| 
     | 
||
| using Dates: DateTime | ||
| 
     | 
||
| include("clima_ocean_copernicus.jl") | ||
                
      
                  simone-silvestri marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| include("veros_ocean_simulation.jl") | ||
| include("veros_state_exchanger.jl") | ||
| 
     | 
||
| end # module ClimaOceanPythonCallExt | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,205 @@ | ||
| using CondaPkg | ||
| 
     | 
||
| using Oceananigans.Grids: topology | ||
| using ClimaOcean.OceanSeaIceModels: reference_density, heat_capacity, SeaIceSimulation | ||
| 
     | 
||
| import Oceananigans.Fields: set! | ||
| import Oceananigans.TimeSteppers: time_step!, initialize! | ||
| 
     | 
||
| import ClimaOcean.OceanSeaIceModels: OceanSeaIceModel, default_nan_checker | ||
| import Oceananigans.Architectures: architecture | ||
| 
     | 
||
| import Base: eltype | ||
| 
     | 
||
| """ | ||
| install_veros() | ||
| 
     | 
||
| Install the Veros ocean model Marine CLI using CondaPkg. | ||
| Returns a NamedTuple containing package information if successful. | ||
| """ | ||
| function install_veros() | ||
| CondaPkg.add("veros"; channel = "conda-forge") | ||
| cli = CondaPkg.which("veros") | ||
| @info "... the veros CLI has been installed at $(cli)." | ||
| return cli | ||
| end | ||
| 
     | 
||
| struct VerosOceanSimulation{S} | ||
| setup :: S | ||
| end | ||
| 
     | 
||
| default_nan_checker(model::OceanSeaIceModel{<:Any, <:Any, <:VerosOceanSimulation}) = nothing | ||
| 
     | 
||
| initialize!(::ClimaOceanPythonCallExt.VerosOceanSimulation{Py}) = nothing | ||
| time_step!(ocean::VerosOceanSimulation, Δt) = ocean.setup.step(ocean.setup.state) | ||
| architecture(model::OceanSeaIceModel{<:Any, <:Any, <:VerosOceanSimulation}) = CPU() | ||
| eltype(model::OceanSeaIceModel{<:Any, <:Any, <:VerosOceanSimulation}) = Float64 | ||
| 
     | 
||
| function remove_outputs(setup::Symbol) | ||
| rm("$(setup).averages.nc", force=true) | ||
| rm("$(setup).energy.nc", force=true) | ||
| rm("$(setup).overturning.nc", force=true) | ||
| rm("$(setup).snapshot.nc", force=true) | ||
| return nothing | ||
| end | ||
| 
     | 
||
| const CCField2D = Field{<:Center, <:Center, <:Nothing} | ||
| const FCField2D = Field{<:Face, <:Center, <:Nothing} | ||
| const CFField2D = Field{<:Center, <:Face, <:Nothing} | ||
| 
     | 
||
| function set!(field::CCField2D, pyarray::Py, k=pyconvert(Int, pyarray.shape[2])) | ||
| array = PyArray(pyarray) | ||
| Nx, Ny, Nz = size(array) | ||
| set!(field, view(array, 3:Nx-2, 3:Ny-2, k, 1)) | ||
| return field | ||
| end | ||
| 
     | 
||
| function set!(field::FCField2D, pyarray::Py, k=pyconvert(Int, pyarray.shape[2])) | ||
| array = PyArray(pyarray) | ||
| Nx, Ny, Nz = size(array) | ||
| TX, TY, _ = topology(field.grid) | ||
| i_indices = TX == Periodic ? UnitRange(3, Nx-2) : UnitRange(2, Nx-2) | ||
| set!(field, view(array, i_indices, 3:Ny-2, k, 1)) | ||
| return field | ||
| end | ||
| 
     | 
||
| function set!(field::CFField2D, pyarray::Py, k=pyconvert(Int, pyarray.shape[2])) | ||
| array = PyArray(pyarray) | ||
| Nx, Ny, Nz = size(array) | ||
| set!(field, view(array, 3:Nx-2, 2:Ny-2, k, 1)) | ||
| return field | ||
| end | ||
| 
     | 
||
| """ | ||
| VerosOceanSimulation(setup, setup_name::Symbol) | ||
| 
     | 
||
| Creates and initializes a preconfigured Veros ocean simulation using the | ||
| specified setup module and setup name. | ||
| 
     | 
||
| Arguments | ||
| ========== | ||
| - `setup::AbstractString`: The name of the Veros setup module to import (e.g., `"global_4deg"`). | ||
| - `setup_name::Symbol`: The name of the setup class or function within the module to instantiate (e.g., `:GlobalFourDegreeSetup`). | ||
| """ | ||
| function VerosOceanSimulation(setup, setup_name::Symbol) | ||
| setups = pyimport("veros.setups." * setup) | ||
| setup = @eval $setups.$setup_name() | ||
| 
     | 
||
| # instantiate the setup | ||
| setup.setup() | ||
| 
     | 
||
| return VerosOceanSimulation(setup) | ||
| end | ||
| 
     | 
||
| """ | ||
| surface_grid(ocean::VerosOceanSimulation) | ||
| 
     | 
||
| Constructs a `LatitudeLongitudeGrid` representing the surface grid of the given `VerosOceanSimulation` object. | ||
| Notes: Veros always uses a LatitudeLongitudeGrid with 2 halos in both the latitude and longitude directions. | ||
| Both latitude and longitude can be either stretched or uniform, depending on the setup, and while the meridional | ||
| direction (latitude) is always Bounded, the zonal direction (longitude) can be either Periodic or Bounded. | ||
| 
     | 
||
| Arguments | ||
| ========== | ||
| - `ocean::VerosOceanSimulation`: The ocean simulation object containing the grid state variables. | ||
| """ | ||
| function surface_grid(ocean::VerosOceanSimulation) | ||
| 
     | 
||
| xf = Array(PyArray(ocean.setup.state.variables.xu)) | ||
| yf = Array(PyArray(ocean.setup.state.variables.yu)) | ||
| 
     | 
||
| xc = Array(PyArray(ocean.setup.state.variables.xt)) | ||
| yc = Array(PyArray(ocean.setup.state.variables.yt)) | ||
| 
     | 
||
| xf = xf[2:end-2] | ||
| yf = yf[2:end-2] | ||
| 
     | 
||
| xc = xc[3:end-2] | ||
| yc = yc[3:end-2] | ||
| 
     | 
||
| xf[1] = xf[2] - 2xc[1] | ||
| yf[1] = sign(yf[2]) * (yf[2] - 2yc[1]) | ||
| 
     | 
||
| TX = if xf[1] == 0 && xf[end] == 360 | ||
| Periodic | ||
| else | ||
| Bounded | ||
| end | ||
| 
     | 
||
| Nx = length(xc) | ||
| Ny = length(yc) | ||
| 
     | 
||
| return LatitudeLongitudeGrid(size=(Nx, Ny), longitude=xf, latitude=yf, topology=(TX, Bounded, Flat), halo=(2, 2)) | ||
| end | ||
| 
     | 
||
| """ | ||
| veros_set!(ocean, v, x) | ||
                
      
                  simone-silvestri marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| Set the `v` variable in the `ocean` model to the value of `x`. | ||
| """ | ||
| function veros_set!(ocean::VerosOceanSimulation, v, x) | ||
| setup = ocean.setup | ||
| pyexec(""" | ||
| with setup.state.variables.unlock(): | ||
| setup.state.variables.__setattr__(y, t) | ||
| """, Main, (y=v, t=x, setup=setup)) | ||
| end | ||
| 
     | 
||
| 
     | 
||
| """ | ||
| veros_settings_set!(ocean, v, x) | ||
| 
     | 
||
| Set the `s` setting in the `ocean` model to the value of `x`. | ||
| """ | ||
| function veros_settings_set!(ocean::VerosOceanSimulation, s, x) | ||
| setup = ocean.setup | ||
| pyexec(""" | ||
| with setup.state.settings.unlock(): | ||
| setup.state.settings.__setattr__(y, t) | ||
| """, Main, (y=s, t=x, setup=setup)) | ||
| end | ||
| 
     | 
||
| function OceanSeaIceModel(ocean::VerosOceanSimulation, sea_ice=nothing; | ||
| atmosphere = nothing, | ||
| radiation = Radiation(), | ||
| clock = Clock(time=0), | ||
| ocean_reference_density = 1020.0, | ||
| ocean_heat_capacity = 3998.0, | ||
| sea_ice_reference_density = reference_density(sea_ice), | ||
| sea_ice_heat_capacity = heat_capacity(sea_ice), | ||
| interfaces = nothing) | ||
| 
     | 
||
| if sea_ice isa SeaIceSimulation | ||
| if !isnothing(sea_ice.callbacks) | ||
| pop!(sea_ice.callbacks, :stop_time_exceeded, nothing) | ||
| pop!(sea_ice.callbacks, :stop_iteration_exceeded, nothing) | ||
| pop!(sea_ice.callbacks, :wall_time_limit_exceeded, nothing) | ||
| pop!(sea_ice.callbacks, :nan_checker, nothing) | ||
| end | ||
| end | ||
| 
     | 
||
| # Contains information about flux contributions: bulk formula, prescribed fluxes, etc. | ||
| if isnothing(interfaces) && !(isnothing(atmosphere) && isnothing(sea_ice)) | ||
| interfaces = ComponentInterfaces(atmosphere, ocean, sea_ice; | ||
| ocean_reference_density, | ||
| ocean_heat_capacity, | ||
| sea_ice_reference_density, | ||
| sea_ice_heat_capacity, | ||
| radiation) | ||
| end | ||
| 
     | 
||
| arch = CPU() | ||
| 
     | 
||
| ocean_sea_ice_model = OceanSeaIceModel(arch, | ||
| clock, | ||
| atmosphere, | ||
| sea_ice, | ||
| ocean, | ||
| interfaces) | ||
| 
     | 
||
| # Make sure the initial temperature of the ocean | ||
| # is not below freezing and above melting near the surface | ||
| initialization_update_state!(ocean_sea_ice_model) | ||
| 
     | 
||
| return ocean_sea_ice_model | ||
| end | ||
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.