├── LICENSE ├── README.md ├── doc ├── cgrid.pdf ├── grid.pdf ├── kelv2.png ├── pyOM2_3.pdf └── pyOM2_3.tex ├── for_config ├── Makefile ├── acc1.f90 ├── acc2.f90 ├── acc3.f90 ├── acc_hi1.f90 ├── acc_small.f90 ├── atmos1.f90 ├── barbi_exp1.f90 ├── eady0.f90 ├── eady1_unscaled.f90 ├── eady_jet1.f90 ├── eady_opv1.f90 ├── eady_opv1.ipynb ├── eady_periodic1.f90 ├── energy1.f90 ├── energy2.f90 ├── internal_wave1.f90 ├── isopyc1.f90 ├── jets1.f90 ├── kelv_helm1.f90 ├── ml_front.f90 ├── overflow1.f90 ├── overflow1_3D.f90 ├── rayleigh1.f90 ├── rayleigh2.f90 ├── roullet1.f90 ├── salt_fountain1.f90 ├── saturn1.f90 ├── shear1.f90 ├── test_adv1.f90 ├── test_bihathk1.f90 ├── test_idemix1.f90 ├── test_idemix2.f90 ├── test_lee1.f90 ├── test_obc1.f90 ├── test_obta1.f90 ├── test_rossmix1.f90 ├── test_rossmix2.f90 ├── test_rossmix3.f90 └── test_tke1.f90 ├── for_src ├── Makefile ├── advection │ ├── Makefile │ ├── adv_2nd.f90 │ ├── adv_dst3.f90 │ ├── adv_main.f90 │ ├── adv_superbee.f90 │ ├── adv_upwind.f90 │ └── adv_upwind3.f90 ├── biha_thk │ ├── Makefile │ ├── biharmonic_thickness_backscatter.f90 │ ├── biharmonic_thickness_diag_snap.f90 │ ├── biharmonic_thickness_friction.f90 │ ├── biharmonic_thickness_main.f90 │ ├── biharmonic_thickness_mixing.f90 │ └── biharmonic_thickness_module.f90 ├── density │ ├── Makefile │ ├── check_density.f90 │ ├── density.f90 │ └── get_rho.f90 ├── diagnostics │ ├── Makefile │ ├── diag_averages.f90 │ ├── diag_energy.f90 │ ├── diag_main.f90 │ ├── diag_opt_balance.f90 │ ├── diag_over.f90 │ ├── diag_particles.f90 │ ├── diag_particles_netcdf.f90 │ ├── diag_snap.f90 │ ├── diag_snap_chunks.f90 │ ├── diag_snap_eke.f90 │ ├── diag_snap_energy.f90 │ ├── diag_snap_fluxes.f90 │ ├── diag_snap_idemix.f90 │ ├── diag_snap_isoneutral.f90 │ ├── diag_snap_parallel.F90 │ ├── diag_snap_rossmix.f90 │ ├── diag_snap_tendency.f90 │ ├── diag_snap_tke.f90 │ ├── diag_snap_tracer.f90 │ ├── diag_variance.f90 │ └── diagnostics_module.f90 ├── eke │ ├── Makefile │ ├── eke.f90 │ └── eke_module.f90 ├── etc │ ├── Makefile │ ├── check_timing.f90 │ ├── py_stuff.f90 │ └── timing_module.f90 ├── external │ ├── Makefile │ ├── island_module.f90 │ ├── solve_pressure.f90 │ ├── solve_streamfct.f90 │ └── streamfct_init.f90 ├── idemix │ ├── Makefile │ ├── idemix.f90 │ ├── idemix3.f90 │ ├── idemix_friction.f90 │ ├── idemix_group_vel.f90 │ ├── idemix_leewaves.f90 │ ├── idemix_low_mode.f90 │ ├── idemix_module.f90 │ └── idemix_spectral.f90 ├── isoneutral │ ├── Makefile │ ├── isoneutral.f90 │ ├── isoneutral_diffusion.f90 │ ├── isoneutral_friction.f90 │ ├── isoneutral_ml.f90 │ └── isoneutral_module.f90 ├── main │ ├── Makefile │ ├── biharmonic_friction.f90 │ ├── bottom_friction.f90 │ ├── diffusion.f90 │ ├── harmonic_friction.f90 │ ├── main.f90 │ ├── main_module.f90 │ ├── momentum.f90 │ ├── momentum_advection.f90 │ ├── numerics.f90 │ ├── restart.f90 │ ├── thermodynamics.f90 │ ├── time_step.f90 │ ├── vertical_friction.f90 │ └── vertical_velocity.f90 ├── non_hydrostatic │ ├── Makefile │ └── non_hydrostatic.f90 ├── obc │ ├── Makefile │ ├── obc.f90 │ └── obc_module.f90 ├── parallel │ ├── Makefile │ ├── parallel_mpi.f90 │ └── parallel_none.f90 ├── rossmix │ ├── Makefile │ ├── rossmix.f90 │ ├── rossmix_flux.f90 │ ├── rossmix_friction.f90 │ ├── rossmix_group_velocity.f90 │ ├── rossmix_integrate.f90 │ ├── rossmix_module.f90 │ └── rossmix_reflect.f90 ├── rossmix2 │ ├── Makefile │ ├── rossmix2.f90 │ ├── rossmix2_diag_snap.f90 │ ├── rossmix2_friction.f90 │ ├── rossmix2_module.f90 │ └── rossmix2_parameter.f90 ├── tke │ ├── Makefile │ ├── tke.f90 │ └── tke_module.f90 ├── tools │ ├── Makefile │ ├── cat_snaps.ipynb │ └── convert_restart.f90 └── tracer │ ├── Makefile │ ├── tracer.f90 │ └── tracer_module.f90 ├── py_config ├── Makefile ├── acc1.py ├── acc2.py ├── channel1.py ├── eady0.py ├── eady1.py ├── eady2.py ├── enso1.py ├── eq_waves1.py ├── holmboe1.py ├── internal_wave1.py ├── jets1.py ├── kelv_helm1.py ├── kelv_helm2.py ├── lin_stab.py ├── rayleigh.py ├── rossby1.py ├── test.py ├── test1.py └── test_tke1.py ├── py_src ├── Makefile ├── pyOM.py ├── pyOM_ave.py ├── pyOM_cdf.py └── pyOM_gui.py ├── site_specific.mk_amd ├── site_specific.mk_intel-mac ├── site_specific.mk_levante ├── site_specific.mk_mistral ├── site_specific.mk_thunder └── site_specific.mk_x86_64-linux /README.md: -------------------------------------------------------------------------------- 1 | # pyOM2 2 | Ocean circulation model with fortran and python frontend 3 | 4 | read ./doc/pyOM2_3.pdf for documentation. 5 | 6 | several model configurations can be found at https://wiki.cen.uni-hamburg.de/ifm/TO/pyOM2 7 | -------------------------------------------------------------------------------- /doc/cgrid.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ceden/pyOM2/4518280bd7a179e1d7ce84c2d84ec2614fe12789/doc/cgrid.pdf -------------------------------------------------------------------------------- /doc/grid.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ceden/pyOM2/4518280bd7a179e1d7ce84c2d84ec2614fe12789/doc/grid.pdf -------------------------------------------------------------------------------- /doc/kelv2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ceden/pyOM2/4518280bd7a179e1d7ce84c2d84ec2614fe12789/doc/kelv2.png -------------------------------------------------------------------------------- /doc/pyOM2_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ceden/pyOM2/4518280bd7a179e1d7ce84c2d84ec2614fe12789/doc/pyOM2_3.pdf -------------------------------------------------------------------------------- /doc/pyOM2_3.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ceden/pyOM2/4518280bd7a179e1d7ce84c2d84ec2614fe12789/doc/pyOM2_3.tex -------------------------------------------------------------------------------- /for_config/Makefile: -------------------------------------------------------------------------------- 1 | 2 | target = with_mpi 3 | code = ../for_src 4 | bin = ../bin 5 | 6 | %.o: %.f90 7 | test -d ${bin} || mkdir ${bin} 8 | cp $< ${code}/config.f90 9 | (cd ${code};make $(target) ) 10 | 11 | %: %.o 12 | mv ${bin}/model.x ${bin}/${@}.x 13 | 14 | clean: 15 | (cd ${code}; make clean) 16 | 17 | -------------------------------------------------------------------------------- /for_config/barbi_exp1.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! Templates for setup 4 | ! Exp. Disturb in Olbers and Eden, JPO, 2003 5 | ! Long Rossby wave propagation 6 | !======================================================================= 7 | 8 | 9 | module config_module 10 | ! use this module only locally in this file 11 | implicit none 12 | real*8, parameter :: N_0 = 2.6e-3 13 | !real*8, allocatable :: temp_back(:,:,:),dtemp_back(:,:,:,:) 14 | real*8, parameter :: x0=30.0, y0=48.0, x_len = 8.0 15 | end module config_module 16 | 17 | 18 | subroutine set_parameter 19 | ! ---------------------------------- 20 | ! set here main parameter 21 | ! ---------------------------------- 22 | use main_module 23 | use config_module 24 | use diagnostics_module 25 | implicit none 26 | 27 | nx=20;nz=15;ny=20 28 | dt_mom = 3600.0 29 | dt_tracer = 3600.0 30 | 31 | enable_superbee_advection = .true. 32 | enable_hor_friction = .true. 33 | A_h=2e3 34 | 35 | !enable_hor_friction = .true.; A_h = (2*degtom)**3*2e-11 36 | !enable_hor_friction_cos_scaling = .true.; hor_friction_cosPower=1 37 | 38 | kappah_0=1.e-4 39 | kappam_0=1.e-3 40 | 41 | congr_epsilon = 1e-12 42 | congr_max_iterations = 50000 43 | enable_streamfunction = .true. 44 | 45 | enable_conserve_energy = .false. 46 | coord_degree = .true. 47 | enable_hydrostatic = .true. 48 | eq_of_state_type = 1 49 | !enable_tempsalt_sources = .true. 50 | 51 | runlen=5*365.0*86400. 52 | !enable_diag_ts_monitor = .true.; ts_monint = dt_mom 53 | enable_diag_snapshots = .true.; snapint = 3*86400 54 | end subroutine set_parameter 55 | 56 | 57 | subroutine set_grid 58 | use main_module 59 | implicit none 60 | real*8 :: ddz(15) = (/50.,70.,100.,140.,190.,240.,290.,340.,390.,440.,490.,540.,590.,640.,690./) 61 | dxt=2.0 62 | dyt=2.0 63 | if (nz == 15) then 64 | dzt = ddz(15:1:-1) 65 | else 66 | call halt_stop('in set grid') 67 | endif 68 | y_origin = 30.0 69 | end subroutine set_grid 70 | 71 | 72 | subroutine set_coriolis 73 | use main_module 74 | implicit none 75 | integer :: j 76 | real*8 :: phi0 = 30.0 /180. *pi,betaloc 77 | betaloc = 2*omega*cos(phi0)/radius 78 | do j=js_pe-onx,je_pe+onx 79 | !coriolis_t(:,j) = 2*omega*sin(phi0) + betaloc*(yt(j)-y_origin)*degtom 80 | coriolis_t(:,j) = 2*omega*sin(yt(j)/180.*pi) 81 | enddo 82 | end subroutine set_coriolis 83 | 84 | 85 | subroutine set_initial_conditions 86 | use main_module 87 | use config_module 88 | use linear_eq_of_state 89 | implicit none 90 | integer :: i,j,k 91 | real*8 :: alpha, t0 92 | 93 | alpha = linear_eq_of_state_drhodt() 94 | !allocate( temp_back(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); temp_back=0.0 95 | !allocate( dtemp_back(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,3) ); dtemp_back=0.0 96 | 97 | do k=1,nz 98 | do j=js_pe-onx,je_pe+onx 99 | do i=is_pe-onx,ie_pe+onx 100 | !temp_back(i,j,k) = 20.0-N_0**2*zt(k)*maskT(i,j,k)*rho_0/(grav*alpha) 101 | t0= 20.0-N_0**2*zt(k)*rho_0/(grav*alpha) 102 | temp(i,j,k,:) = (t0-0.5*exp(-(xt(i)-x0)**2/x_len**2-(yt(j)-y0)**2/x_len**2)*exp(zt(k)/500.))*maskT(i,j,k) 103 | enddo 104 | enddo 105 | enddo 106 | end subroutine set_initial_conditions 107 | 108 | 109 | subroutine set_forcing 110 | use main_module 111 | use config_module 112 | implicit none 113 | 114 | ! update density, etc of last time step 115 | !temp(:,:,:,tau) = temp(:,:,:,tau) + temp_back 116 | !call calc_eq_of_state(tau) 117 | !temp(:,:,:,tau) = temp(:,:,:,tau) - temp_back 118 | 119 | ! advection of background temperature 120 | !call advect_tracer(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,temp_back,dtemp_back(:,:,:,tau)) 121 | !temp_source = (1.5+ab_eps)*dtemp_back(:,:,:,tau) - ( 0.5+ab_eps)*dtemp_back(:,:,:,taum1) 122 | end subroutine set_forcing 123 | 124 | 125 | subroutine set_topography 126 | use main_module 127 | use config_module 128 | implicit none 129 | kbot=0 130 | kbot(is_pe:ie_pe,js_pe:je_pe)=1 131 | end subroutine set_topography 132 | 133 | 134 | subroutine set_diagnostics 135 | end subroutine set_diagnostics 136 | 137 | 138 | 139 | 140 | 141 | subroutine set_particles 142 | end subroutine set_particles 143 | 144 | -------------------------------------------------------------------------------- /for_config/eady1_unscaled.f90: -------------------------------------------------------------------------------- 1 | 2 | ! two balanced jets with small perturbation get unstable 3 | ! testing optimal balance with time averaging 4 | 5 | module config_module 6 | ! use this module only locally in this file 7 | implicit none 8 | integer,parameter :: fac=1 9 | real*8,parameter :: Ri = 2000 ! Richardson number 10 | real*8,parameter :: delta = 0.02 ! aspect ratio 11 | real*8,parameter :: H0 = 1000.0 ! total depth 12 | real*8 :: Lx,Ly,Lz,f0,N0,U0_loc,M0,kmax,jet_scale 13 | end module config_module 14 | 15 | 16 | 17 | subroutine set_parameter 18 | use main_module 19 | use config_module 20 | use diagnostics_module 21 | use diag_opt_balance_module 22 | implicit none 23 | 24 | f0 = 1e-4 25 | N0 = f0/delta 26 | U0_loc = sqrt(1./Ri)*N0*H0 27 | M0 = sqrt(f0*U0_loc/H0) 28 | kmax = 1./ ( sqrt(2./5.)*sqrt(1+Ri)*M0**2/f0**2*H0 ) 29 | Lx = 4*2/kmax *pi 30 | Ly = 4*2/kmax *pi * 2 31 | Lz = H0 32 | jet_scale = 0.1*Ly/2 33 | 34 | 35 | 36 | nx=30*fac; ny=30*2*fac; nz = 10*fac 37 | congr_max_iterations = 5000 38 | enable_free_surface = .true. 39 | congr_epsilon = 1e-9 40 | enable_hydrostatic = .true. 41 | enable_cyclic_x = .true. 42 | enable_cyclic_y = .true. 43 | enable_conserve_energy = .false. 44 | coord_degree = .false. 45 | eq_of_state_type = 1 46 | 47 | AB_eps = 0.01 48 | dt_mom = 200./fac 49 | dt_tracer = dt_mom 50 | runlen = 86400.0*4500 51 | enable_diag_ts_monitor = .true.; ts_monint = 86400*5 52 | enable_diag_snapshots = .true.; snapint = 86400*5. 53 | 54 | enable_diag_opt_balance = .true.; opt_balance_int = 86400*5. 55 | opt_balance_max_Itts = 3 56 | opt_balance_period = 10./f0 57 | opt_balance_average = 2*86400. 58 | opt_balance_temp_only = .true. 59 | opt_balance_average_times = 5 60 | 61 | 62 | end subroutine set_parameter 63 | 64 | subroutine set_grid 65 | use main_module 66 | use config_module 67 | implicit none 68 | dxt=Lx/nx;dyt=Ly/ny;dzt=Lz/nz 69 | end subroutine set_grid 70 | 71 | 72 | subroutine set_coriolis 73 | use main_module 74 | use config_module 75 | implicit none 76 | coriolis_t = f0 77 | end subroutine set_coriolis 78 | 79 | 80 | subroutine set_initial_conditions 81 | use main_module 82 | use config_module 83 | use diagnostics_module 84 | use diag_opt_balance_module 85 | implicit none 86 | integer :: i,j,k 87 | real*8 :: aloc(nx,ny),bloc(nx,ny) 88 | real*8 :: alpha,get_drhodT 89 | 90 | do k=1,nz 91 | do j=js_pe,je_pe 92 | do i=is_pe,ie_pe 93 | u(i,j,k,tau) = U0_loc*( exp(-(yt(j)-1*Ly/4)**2/jet_scale**2) & 94 | -exp(-(yt(j)-3*Ly/4)**2/jet_scale**2 ) & 95 | + 0.05*sin(xt(i)/Lx*4*pi)*sin(yt(j)/Ly*2*pi) ) *cos(pi*zt(k)/H0) 96 | enddo 97 | enddo 98 | enddo 99 | call border_exchg_xyz(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,u(:,:,:,tau)) 100 | call setcyclic_xyz (is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,u(:,:,:,tau)) 101 | 102 | do k=2,nz-1 103 | do j=js_pe,je_pe 104 | do i=is_pe,ie_pe 105 | aloc(i,j) = -Ly/ny*(u(i,j,k+1,tau)-u(i,j,k-1,tau))/(2*Lz/nz) *f0 106 | enddo 107 | enddo 108 | call pe0_recv_2D(nx,ny,aloc) 109 | bloc(:,1)=0. 110 | do j=1,ny-1 111 | bloc(:,j+1) = bloc(:,j) + aloc(:,j) 112 | enddo 113 | call pe0_bcast(bloc,nx*ny) 114 | temp(is_pe:ie_pe,js_pe:je_pe,k,tau)= bloc(is_pe:ie_pe,js_pe:je_pe) 115 | enddo 116 | temp(:,:,1,tau) = temp(:,:,2,tau) 117 | temp(:,:,nz,tau) = temp(:,:,nz-1,tau) 118 | 119 | 120 | do k=1,nz 121 | temp(:,:,k,tau) = temp(:,:,k,tau) + N0**2*zt(k)*maskT(:,:,k) 122 | enddo 123 | 124 | salt = 35.0 125 | alpha = get_drhodT(35d0,5d0,0d0) 126 | temp = -temp*rho_0/grav/alpha 127 | 128 | 129 | if (enable_diag_opt_balance .and. .true. ) then 130 | 131 | call diag_opt_balance() 132 | 133 | do i=is_pe,ie_pe 134 | do j=js_pe,je_pe 135 | do k=1,nz 136 | u(i,j,k,:) = u_bal(i,j,k) 137 | v(i,j,k,:) = v_bal(i,j,k) 138 | w(i,j,k,:) = w_bal(i,j,k) 139 | temp(i,j,k,:) = temp_bal(i,j,k) + temp_ave(i,j,k) 140 | psi(i,j,:) = psi_bal(i,j) 141 | enddo 142 | enddo 143 | enddo 144 | 145 | 146 | 147 | do i=1,3 148 | ! boundary exchange 149 | call border_exchg_xyz(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,temp(:,:,:,i)) 150 | call setcyclic_xyz (is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,temp(:,:,:,i)) 151 | call border_exchg_xyz(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,salt(:,:,:,i)) 152 | call setcyclic_xyz (is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,salt(:,:,:,i)) 153 | call border_exchg_xyz(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,u(:,:,:,i)) 154 | call setcyclic_xyz (is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,u(:,:,:,i)) 155 | call border_exchg_xyz(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,v(:,:,:,i)) 156 | call setcyclic_xyz (is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,v(:,:,:,i)) 157 | call border_exchg_xyz(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,w(:,:,:,i)) 158 | call setcyclic_xyz (is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,v(:,:,:,i)) 159 | call border_exchg_xy(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,psi(:,:,i)) 160 | call setcyclic_xy (is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,psi(:,:,i)) 161 | 162 | enddo 163 | 164 | endif 165 | 166 | end subroutine set_initial_conditions 167 | 168 | 169 | subroutine set_forcing 170 | end subroutine set_forcing 171 | 172 | 173 | subroutine set_topography 174 | use main_module 175 | implicit none 176 | kbot=1 177 | end subroutine set_topography 178 | 179 | 180 | subroutine set_diagnostics 181 | end subroutine set_diagnostics 182 | 183 | 184 | subroutine set_particles 185 | end subroutine set_particles 186 | -------------------------------------------------------------------------------- /for_config/energy1.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! test for convergence of energetics in simple setup 4 | !======================================================================= 5 | 6 | 7 | module config_module 8 | ! use this module only locally in this file 9 | implicit none 10 | !real*8 :: y0 = 20, y1 = 28, y2=32 11 | real*8 :: y0 = -20, y1 = -12, y2=5 12 | end module config_module 13 | 14 | 15 | 16 | 17 | subroutine set_parameter 18 | ! ---------------------------------- 19 | ! set here main parameter 20 | ! ---------------------------------- 21 | use main_module 22 | use eke_module 23 | use tke_module 24 | use idemix_module 25 | use isoneutral_module 26 | use diagnostics_module 27 | implicit none 28 | 29 | !nx = 5; nz = 8; ny = 18 30 | nx = 5; nz = 8; ny = 42 31 | dt_mom = 3600/2.0 32 | dt_tracer = 86400*0.5 33 | 34 | coord_degree = .true. 35 | enable_cyclic_x = .true. 36 | 37 | runlen = 365*86400.*2000 38 | 39 | enable_diag_ts_monitor = .true.; ts_monint = 86400.*365!/12. 40 | enable_diag_snapshots = .true.; snapint = 86400.*365!/12. 41 | enable_diag_tracer_content = .true.; trac_cont_int = 86400.*365 42 | enable_diag_energy = .true.; energint = 86400.*365; energfreq = 86400.*365 43 | 44 | congr_epsilon = 1e-9 45 | enable_streamfunction = .true. 46 | congr_max_iterations = 15000 47 | 48 | enable_hor_friction = .true.; A_h = (1*degtom)**3*2e-11 49 | enable_hor_friction_cos_scaling = .true.; hor_friction_cosPower=1 50 | enable_bottom_friction = .true.; r_bot = 1e-5 51 | 52 | !enable_superbee_advection = .true. 53 | 54 | !enable_hor_diffusion = .true.; K_h = 1000.0 55 | enable_neutral_diffusion = .true.; 56 | K_iso_0 = 1000.0 57 | K_iso_steep = 1000.0 58 | iso_dslope=4./1000.0 59 | iso_slopec=4./1000.0 60 | enable_skew_diffusion = .true. 61 | !enable_TEM_friction = .true. 62 | 63 | enable_implicit_vert_friction = .true.; 64 | enable_tke = .true. 65 | c_k = 0.1 66 | c_eps = 0.7 67 | alpha_tke = 30.0 68 | mxl_min = 1d-8 69 | tke_mxl_choice = 2 70 | 71 | K_gm_0 = 1000.0 72 | enable_idemix = .true. 73 | 74 | eq_of_state_type = 3 75 | end subroutine set_parameter 76 | 77 | 78 | 79 | subroutine set_grid 80 | use main_module 81 | use config_module 82 | implicit none 83 | real*8 :: ddz(15) = (/50.,70.,100.,140.,190.,240.,290.,340.,390.,440.,490.,540.,590.,640.,690./) 84 | dxt = 1.0 85 | dyt = 1.0 86 | x_origin= 0.0 87 | y_origin= y0 88 | ddz = ddz(15:1:-1)/2.5 89 | dzt = ddz(8:15) 90 | end subroutine set_grid 91 | 92 | 93 | subroutine set_coriolis 94 | use main_module 95 | implicit none 96 | integer :: j 97 | do j=js_pe-onx,je_pe+onx 98 | coriolis_t(:,j) = 2*omega*sin( yt(j)/180.*pi ) 99 | enddo 100 | end subroutine set_coriolis 101 | 102 | 103 | 104 | subroutine set_initial_conditions 105 | use main_module 106 | use config_module 107 | use idemix_module 108 | use tke_module 109 | implicit none 110 | integer :: i,j,k 111 | real*8 :: y 112 | do k=1,nz 113 | do j=js_pe-onx,je_pe+onx 114 | do i=is_pe-onx,ie_pe+onx 115 | y = yt(j)/yt(ny) 116 | salt(i,j,k,:) = 35 117 | temp(i,j,k,:) = (1-zt(k)/zw(1))*15 + 2*(tanh((y-0.5)/0.1)+1.0) + 3*(tanh(-(y-0.5)/0.2)+1.0) 118 | enddo 119 | enddo 120 | enddo 121 | 122 | 123 | do j=js_pe-onx,je_pe+onx 124 | do i=is_pe-onx,ie_pe+onx 125 | if ( yt(j)< y1) surface_taux(i,j) =.02e-3*sin(pi*(yu(j)-yu(1))/(y1-yt(1)))*maskU(i,j,nz) 126 | enddo 127 | enddo 128 | 129 | if (enable_idemix ) then 130 | do j=js_pe-onx,je_pe+onx 131 | do i=is_pe-onx,ie_pe+onx 132 | forc_iw_bottom(i,j) = 1e-6 133 | forc_iw_surface(i,j) = 0.1e-6 134 | enddo 135 | enddo 136 | endif 137 | 138 | if (enable_tke ) then 139 | do j=js_pe-onx+1,je_pe+onx 140 | do i=is_pe-onx+1,ie_pe+onx 141 | forc_tke_surface(i,j) = sqrt( (0.5*(surface_taux(i,j)+surface_taux(i-1,j)))**2 & 142 | +(0.5*(surface_tauy(i,j)+surface_tauy(i,j-1)))**2 )**(3./2.) 143 | enddo 144 | enddo 145 | endif 146 | 147 | end subroutine set_initial_conditions 148 | 149 | 150 | 151 | 152 | function tstar(j) 153 | use main_module 154 | use config_module 155 | implicit none 156 | integer :: j 157 | real*8 :: tstar 158 | tstar=15 159 | if (yt(j)y2) tstar=15*(1-(yt(j)-y2)/(yt(ny)-y2) ) 161 | end function tstar 162 | 163 | 164 | 165 | subroutine set_forcing 166 | use main_module 167 | implicit none 168 | integer :: i,j 169 | real*8 :: tstar 170 | 171 | do j=js_pe-onx,je_pe+onx 172 | do i=is_pe-onx,ie_pe+onx 173 | forc_temp_surface(i,j)=dzt(nz)/(30.*86400.)*(tstar(j)-temp(i,j,nz,tau)) 174 | enddo 175 | enddo 176 | end subroutine set_forcing 177 | 178 | 179 | 180 | subroutine set_topography 181 | use main_module 182 | use config_module 183 | implicit none 184 | integer :: i,j 185 | kbot=0 186 | do i=is_pe,ie_pe 187 | do j=js_pe,je_pe 188 | if ( (yt(j)xt(1))) kbot(i,j)=1 189 | enddo 190 | enddo 191 | end subroutine set_topography 192 | 193 | 194 | 195 | 196 | 197 | subroutine set_diagnostics 198 | end subroutine set_diagnostics 199 | -------------------------------------------------------------------------------- /for_config/energy2.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! same as acc2.f90 4 | !======================================================================= 5 | 6 | 7 | module config_module 8 | ! use this module only locally in this file 9 | implicit none 10 | real*8 :: y0 = -40, y1 = -20, y2=20 11 | real*8 :: hres = 2.0 12 | end module config_module 13 | 14 | 15 | 16 | 17 | subroutine set_parameter 18 | ! ---------------------------------- 19 | ! set here main parameter 20 | ! ---------------------------------- 21 | use main_module 22 | use config_module 23 | use eke_module 24 | use tke_module 25 | use idemix_module 26 | use isoneutral_module 27 | use diagnostics_module 28 | implicit none 29 | 30 | nx = 5; nz = 15; ny = ceiling(42/hres) 31 | dt_mom = 3600 *1.5 32 | dt_tracer = 86400*hres 33 | 34 | coord_degree = .true. 35 | enable_cyclic_x = .true. 36 | 37 | runlen = 365*86400.*2000 38 | 39 | enable_diag_ts_monitor = .true.; ts_monint = 86400.*365!/12. 40 | enable_diag_snapshots = .true.; snapint = 86400.*365!/12. 41 | enable_diag_tracer_content = .true.; trac_cont_int = 86400.*365 42 | enable_diag_energy = .true.; energint = 86400.*365; energfreq = 86400.*365 43 | 44 | congr_epsilon = 1e-9 45 | enable_streamfunction = .true. 46 | congr_max_iterations = 15000 47 | 48 | enable_hor_friction = .true.; A_h = (2*degtom*hres)**3*2e-11 49 | enable_hor_friction_cos_scaling = .true.; hor_friction_cosPower=1 50 | enable_bottom_friction = .true.; r_bot = 1e-5 51 | 52 | !enable_superbee_advection = .true. 53 | 54 | !enable_hor_diffusion = .true.; K_h = 1000.0 55 | enable_neutral_diffusion = .true.; 56 | K_iso_0 = 1000.0 57 | K_iso_steep = 1000.0 58 | iso_dslope=4./1000.0 59 | iso_slopec=4./1000.0 60 | enable_skew_diffusion = .true. 61 | !enable_TEM_friction = .true. 62 | 63 | enable_implicit_vert_friction = .true.; 64 | enable_tke = .true. 65 | c_k = 0.1 66 | c_eps = 0.7 67 | alpha_tke = 30.0 68 | mxl_min = 1d-8 69 | tke_mxl_choice = 2 70 | enable_tke_hor_diffusion = .true. 71 | K_h_tke = 1000.0 72 | 73 | K_gm_0 = 1000.0 74 | enable_idemix = .true. 75 | 76 | eq_of_state_type = 3 77 | end subroutine set_parameter 78 | 79 | 80 | 81 | subroutine set_grid 82 | use main_module 83 | use config_module 84 | implicit none 85 | real*8 :: ddz(15) = (/50.,70.,100.,140.,190.,240.,290.,340.,390.,440.,490.,540.,590.,640.,690./) 86 | dxt = 2.0*hres 87 | dyt = 2.0*hres 88 | x_origin= 0.0 89 | y_origin= y0 90 | ddz = ddz(15:1:-1)/2.5 91 | dzt = ddz 92 | end subroutine set_grid 93 | 94 | 95 | subroutine set_coriolis 96 | use main_module 97 | implicit none 98 | integer :: j 99 | do j=js_pe-onx,je_pe+onx 100 | coriolis_t(:,j) = 2*omega*sin( yt(j)/180.*pi ) 101 | enddo 102 | end subroutine set_coriolis 103 | 104 | 105 | 106 | subroutine set_initial_conditions 107 | use main_module 108 | use config_module 109 | use idemix_module 110 | use tke_module 111 | implicit none 112 | integer :: i,j,k 113 | real*8 :: y 114 | do k=1,nz 115 | do j=js_pe-onx,je_pe+onx 116 | do i=is_pe-onx,ie_pe+onx 117 | y = yt(j)/yt(ny) 118 | salt(i,j,k,:) = 35 119 | temp(i,j,k,:) = (1-zt(k)/zw(1))*15 + 2*(tanh((y-0.5)/0.1)+1.0) + 3*(tanh(-(y-0.5)/0.2)+1.0) 120 | enddo 121 | enddo 122 | enddo 123 | 124 | 125 | do j=js_pe-onx,je_pe+onx 126 | do i=is_pe-onx,ie_pe+onx 127 | if ( yt(j)< y1) surface_taux(i,j) =.02e-3*sin(pi*(yu(j)-yu(1))/(y1-yt(1)))*maskU(i,j,nz) 128 | enddo 129 | enddo 130 | 131 | if (enable_idemix ) then 132 | do j=js_pe-onx,je_pe+onx 133 | do i=is_pe-onx,ie_pe+onx 134 | forc_iw_bottom(i,j) = 1e-6 135 | forc_iw_surface(i,j) = 0.1e-6 136 | enddo 137 | enddo 138 | endif 139 | 140 | if (enable_tke ) then 141 | do j=js_pe-onx+1,je_pe+onx 142 | do i=is_pe-onx+1,ie_pe+onx 143 | forc_tke_surface(i,j) = sqrt( (0.5*(surface_taux(i,j)+surface_taux(i-1,j)))**2 & 144 | +(0.5*(surface_tauy(i,j)+surface_tauy(i,j-1)))**2 )**(3./2.) 145 | enddo 146 | enddo 147 | endif 148 | 149 | end subroutine set_initial_conditions 150 | 151 | 152 | 153 | 154 | function tstar(j) 155 | use main_module 156 | use config_module 157 | implicit none 158 | integer :: j 159 | real*8 :: tstar 160 | tstar=15 161 | if (yt(j)y2) tstar=15*(1-(yt(j)-y2)/(yt(ny)-y2) ) 163 | end function tstar 164 | 165 | 166 | 167 | subroutine set_forcing 168 | use main_module 169 | implicit none 170 | integer :: i,j 171 | real*8 :: tstar 172 | 173 | do j=js_pe-onx,je_pe+onx 174 | do i=is_pe-onx,ie_pe+onx 175 | forc_temp_surface(i,j)=dzt(nz)/(30.*86400.)*(tstar(j)-temp(i,j,nz,tau)) 176 | enddo 177 | enddo 178 | end subroutine set_forcing 179 | 180 | 181 | 182 | subroutine set_topography 183 | use main_module 184 | use config_module 185 | implicit none 186 | integer :: i,j 187 | kbot=0 188 | do i=is_pe,ie_pe 189 | do j=js_pe,je_pe 190 | if ( (yt(j)xt(1))) kbot(i,j)=1 191 | enddo 192 | enddo 193 | end subroutine set_topography 194 | 195 | 196 | 197 | 198 | 199 | subroutine set_diagnostics 200 | end subroutine set_diagnostics 201 | -------------------------------------------------------------------------------- /for_config/internal_wave1.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | !======================================================================= 4 | ! Internal wave maker 5 | !======================================================================= 6 | 7 | module config_module 8 | use main_module 9 | real*8 :: fac=2.0 10 | real*8 :: N_0 = 2*pi/10. 11 | real*8 :: OM0 = 1./(1.5*10),x0 12 | real*8, allocatable :: t0(:,:,:),dt0(:,:,:,:),u0(:,:,:) 13 | end module config_module 14 | 15 | subroutine set_parameter 16 | use main_module 17 | use config_module 18 | use diagnostics_module 19 | use tke_module 20 | implicit none 21 | ny=1 22 | nx=int(64*fac) 23 | nz=int(64*fac) 24 | 25 | dt_mom = 20*0.025/fac 26 | dt_tracer= 20*0.025/fac 27 | 28 | enable_conserve_energy = .false. 29 | coord_degree = .false. 30 | enable_cyclic_x = .true. 31 | enable_hydrostatic = .false. 32 | eq_of_state_type = 1 33 | 34 | congr_epsilon = 1e-12 35 | congr_max_iterations = 5000 36 | congr_epsilon_non_hydro= 1e-9 37 | congr_max_itts_non_hydro = 5000 38 | 39 | enable_explicit_vert_friction = .true. 40 | kappam_0 = 5e-3/fac**2 41 | enable_hor_friction = .true. 42 | a_h = 5e-3/fac**2 43 | enable_superbee_advection = .true. 44 | 45 | enable_tempsalt_sources = .true. 46 | enable_momentum_sources = .true. 47 | 48 | runlen = 86400.0 49 | enable_diag_ts_monitor = .true.; ts_monint = 0.5!dt_mom 50 | enable_diag_snapshots = .true.; snapint = 5.0!dt_mom 51 | 52 | end subroutine set_parameter 53 | 54 | 55 | subroutine set_grid 56 | use main_module 57 | use config_module 58 | implicit none 59 | dxt(:)=0.25/fac 60 | dyt(:)=0.25/fac 61 | dzt(:)=0.25/fac 62 | end subroutine set_grid 63 | 64 | 65 | 66 | subroutine set_initial_conditions 67 | use main_module 68 | use config_module 69 | implicit none 70 | integer :: i,k 71 | real*8 :: alpha,get_drhodT 72 | 73 | alpha = get_drhodT(35d0,5d0,0d0) 74 | allocate( t0(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); t0 = 0 75 | allocate( u0(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); u0 = 0 76 | allocate( dt0(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,3) ); dt0 = 0 77 | do k=1,nz 78 | t0(:,:,k)=-N_0**2*zt(k)/9.81/alpha*rho_0*maskT(:,:,k) 79 | enddo 80 | x0 = 0.0; if (nx/2 >= is_pe .and. nx/2<= ie_pe) x0 = xu(nx/2) 81 | call global_max(x0) 82 | do k=1,nz 83 | do i=is_pe,ie_pe 84 | u0(i,:,k)= maskU(i,:,k)*1./(100*60.*dt_tracer)*exp( -(xu(i)-x0)**2/(dxt(is_pe)*1)**2 ) & 85 | *exp( -(zt(k)-zt(nz/2))**2/(dzt(1)*1)**2 ) 86 | enddo 87 | enddo 88 | end subroutine set_initial_conditions 89 | 90 | 91 | 92 | 93 | subroutine set_forcing 94 | use main_module 95 | use config_module 96 | implicit none 97 | 98 | ! implement effect of background state 99 | 100 | ! update density, etc of last time step 101 | temp(:,:,:,tau) = temp(:,:,:,tau) + t0 102 | call calc_eq_of_state(tau) 103 | temp(:,:,:,tau) = temp(:,:,:,tau) - t0 104 | 105 | ! advection of background temperature 106 | call advect_tracer(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,t0,dt0(:,:,:,tau)) 107 | temp_source = (1.5+ab_eps)*dt0(:,:,:,tau) - ( 0.5+ab_eps)*dt0(:,:,:,taum1) 108 | 109 | ! wavemaker 110 | u_source= u0*sin(2*pi*OM0*itt*dt_tracer) 111 | 112 | end subroutine set_forcing 113 | 114 | subroutine set_coriolis 115 | end subroutine set_coriolis 116 | 117 | subroutine set_topography 118 | use main_module 119 | implicit none 120 | kbot =1 121 | end subroutine set_topography 122 | 123 | 124 | subroutine set_diagnostics 125 | end subroutine set_diagnostics 126 | 127 | 128 | subroutine set_particles 129 | end subroutine set_particles 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /for_config/isopyc1.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! test for isopycnal mixing 4 | !======================================================================= 5 | 6 | 7 | 8 | subroutine set_parameter 9 | ! ---------------------------------- 10 | ! set here main parameter 11 | ! ---------------------------------- 12 | use main_module 13 | use eke_module 14 | use tke_module 15 | use idemix_module 16 | use isoneutral_module 17 | use diagnostics_module 18 | implicit none 19 | 20 | nx = 1; nz = 15; ny = 30 21 | dt_mom = 3600/2.0 22 | dt_tracer = 86400*0.5 23 | 24 | coord_degree = .true. 25 | enable_cyclic_x = .true. 26 | 27 | runlen = 365*86400.*2000 28 | 29 | enable_diag_ts_monitor = .true.; ts_monint = 86400.*365!/12. 30 | enable_diag_snapshots = .true.; snapint = 86400.*365!/12. 31 | !enable_diag_tracer_content = .true.; trac_cont_int = 86400.*365 32 | 33 | enable_momentum_equation = .false. 34 | !enable_thermodynamic_equation = .false. 35 | congr_epsilon = 1e-9 36 | !enable_streamfunction = .true. 37 | congr_max_iterations = 15000 38 | 39 | enable_hor_friction = .true.; A_h = (1*degtom)**3*2e-11 40 | enable_hor_friction_cos_scaling = .true.; hor_friction_cosPower=1 41 | 42 | !enable_hor_diffusion = .true.; K_h = 1000.0 43 | enable_neutral_diffusion = .true.; 44 | K_iso_0 = 1000.0 45 | K_iso_steep = 1000.0 46 | iso_dslope=4./1000.0 47 | iso_slopec=4./1000.0 48 | enable_skew_diffusion = .true. 49 | !enable_TEM_friction = .true. 50 | 51 | K_gm_0 = 1000.0 52 | enable_conserve_energy = .false. 53 | eq_of_state_type = 5 54 | end subroutine set_parameter 55 | 56 | 57 | 58 | subroutine set_grid 59 | use main_module 60 | implicit none 61 | real*8 :: ddz(15) = (/50.,70.,100.,140.,190.,240.,290.,340.,390.,440.,490.,540.,590.,640.,690./) 62 | dxt = 1.0 63 | dyt = 1.0 64 | x_origin= 0.0 65 | y_origin= 20.0 66 | dzt = ddz(15:1:-1)/2.5 67 | end subroutine set_grid 68 | 69 | 70 | subroutine set_coriolis 71 | use main_module 72 | implicit none 73 | real*8 :: phi0,betaloc 74 | integer :: j 75 | phi0 = 25.0 /180. *pi 76 | betaloc = 2*omega*cos(phi0)/radius 77 | do j=js_pe-onx,je_pe+onx 78 | coriolis_t(:,j) = 1e-4 +betaloc*yt(j) 79 | enddo 80 | end subroutine set_coriolis 81 | 82 | 83 | subroutine set_initial_conditions 84 | use main_module 85 | use idemix_module 86 | use tke_module 87 | implicit none 88 | integer :: i,j,k 89 | real*8 :: y 90 | do k=1,nz 91 | do j=js_pe-onx,je_pe+onx 92 | do i=is_pe-onx,ie_pe+onx 93 | y = yt(j)/yt(ny) 94 | salt(i,j,k,:) = 35 95 | !salt(i,j,k,:) = exp( -(zt(k) - zt(1)/2)**2/300**2 - (yt(j)-yt(ny)/2)**2/50e3**2 ) 96 | temp(i,j,k,:) = (1-zt(k)/zw(1))*15 + 2*(tanh((y-0.5)/0.1)+1.0) + 3*(tanh(-(y-0.5)/0.2)+1.0) 97 | enddo 98 | enddo 99 | enddo 100 | 101 | 102 | !do j=js_pe-onx,je_pe+onx 103 | ! do i=is_pe-onx,ie_pe+onx 104 | ! if (j<=15) temp(i,j,nz-7:nz,tau) = temp(i,j,nz-8,tau) 105 | ! if (j<=15) temp(i,j,nz-7:nz,taum1) = temp(i,j,nz-8,taum1) 106 | ! enddo 107 | !enddo 108 | end subroutine set_initial_conditions 109 | 110 | subroutine set_momentum_forcing 111 | end subroutine set_momentum_forcing 112 | 113 | subroutine set_forcing 114 | end subroutine set_forcing 115 | 116 | subroutine set_topography 117 | use main_module 118 | implicit none 119 | !kbot=0 120 | !kbot(1:nx,1:ny)=1 121 | kbot=1 122 | end subroutine set_topography 123 | 124 | subroutine set_diagnostics 125 | end subroutine set_diagnostics 126 | 127 | subroutine set_particles 128 | end subroutine set_particles 129 | -------------------------------------------------------------------------------- /for_config/kelv_helm1.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! Kelvin Helmholtz instability 4 | !======================================================================= 5 | 6 | module config_module 7 | real*8 :: fac=1.0,mix=5e-3 8 | end module config_module 9 | 10 | subroutine set_parameter 11 | use main_module 12 | use config_module 13 | use diagnostics_module 14 | use tke_module 15 | implicit none 16 | ny=1 17 | nx=int(1.5*64*fac) 18 | nz=int(40*fac) 19 | 20 | dt_mom=0.04/fac 21 | dt_tracer = dt_mom 22 | 23 | enable_conserve_energy = .false. 24 | coord_degree =.false. 25 | enable_cyclic_x =.true. 26 | enable_hydrostatic =.false. 27 | eq_of_state_type = 1 28 | 29 | congr_epsilon = 1d-12 30 | congr_max_iterations = 5000 31 | !enable_streamfunction = .true. 32 | 33 | congr_epsilon_non_hydro= 1d-6 34 | congr_max_itts_non_hydro = 5000 35 | 36 | enable_tempsalt_sources = .true. 37 | enable_momentum_sources = .true. 38 | 39 | enable_explicit_vert_friction = .true.; kappaM_0 = mix/fac**2 40 | enable_hor_friction = .true.; A_h = mix/fac**2 41 | enable_superbee_advection =.true. 42 | !kappaH_0 = mix/fac**2 43 | !enable_hor_diffusion = .true.; K_h = mix/fac**2 44 | 45 | runlen = 86400.0 46 | enable_diag_ts_monitor = .true.; ts_monint =0.5!dt_mom 47 | enable_diag_snapshots = .true.; snapint = 0.5!dt_mom 48 | 49 | !enable_diag_particles = .true.; particles_int = 0.5 50 | end subroutine set_parameter 51 | 52 | 53 | subroutine set_grid 54 | use main_module 55 | use config_module 56 | implicit none 57 | dxt(:)=0.25/fac 58 | dyt(:)=0.25/fac 59 | dzt(:)=0.25/fac 60 | end subroutine set_grid 61 | 62 | subroutine set_coriolis 63 | !use main_module 64 | !use config_module 65 | !implicit none 66 | !coriolis_t = 2*omega*sin( 30./180.*pi) 67 | !coriolis_h = 2*omega*cos( 30./180.*pi) 68 | end subroutine set_coriolis 69 | 70 | 71 | real*8 function t_star(k) 72 | use main_module 73 | implicit none 74 | integer :: k 75 | t_star=9.85-6.5*tanh( (zt(k)-zt(nz/2) ) /zt(1)*100 ) 76 | end function t_star 77 | 78 | 79 | real*8 function u_star(k) 80 | use main_module 81 | implicit none 82 | integer :: k 83 | u_star=0.6+0.5*tanh( (zt(k)-zt(nz/2))/zt(1)*100) 84 | end function u_star 85 | 86 | 87 | 88 | subroutine set_initial_conditions 89 | use main_module 90 | implicit none 91 | integer :: i,j,k 92 | real*8 :: fxa,t_star,u_star 93 | do k=1,nz 94 | do j=js_pe-onx,je_pe+onx 95 | do i=is_pe-onx,ie_pe+onx 96 | fxa=1e-3*zt(1)*sin(xt(i)/(20*dxt(is_pe))*pi) 97 | temp(i,j,k,:)=( fxa+t_star(k) )*maskT(i,j,k) 98 | u(i,j,k,:) = u_star(k)*maskU(i,j,k) 99 | enddo 100 | enddo 101 | enddo 102 | end subroutine set_initial_conditions 103 | 104 | 105 | 106 | 107 | subroutine set_forcing 108 | use main_module 109 | implicit none 110 | integer :: i,k 111 | real*8 :: T_rest,t_star,u_star 112 | T_rest=1./(15.*dt_mom) 113 | do k=1,nz 114 | do i=2,nx/8 115 | if (i>=is_pe .and. i<=ie_pe) then 116 | temp_source(i,:,k)=maskT(i,:,k)*T_rest*(t_star(k)-temp(i,:,k,tau)) 117 | u_source(i,:,k) = maskU(i,:,k)*T_rest*(u_star(k)-u(i,:,k,tau)) 118 | endif 119 | enddo 120 | enddo 121 | end subroutine set_forcing 122 | 123 | 124 | 125 | subroutine set_topography 126 | use main_module 127 | implicit none 128 | kbot =1 129 | end subroutine set_topography 130 | 131 | 132 | subroutine set_diagnostics 133 | end subroutine set_diagnostics 134 | 135 | 136 | subroutine set_particles 137 | use main_module 138 | use particles_module 139 | implicit none 140 | integer :: n 141 | real :: fxa,xs,xe,zs,ze 142 | 143 | call allocate_particles(2000) 144 | xs=0;xe=nx*dxt(is_pe); 145 | zs=zt(1);ze=zt(nz) 146 | do n=1,nptraj 147 | call random_number(fxa) 148 | pxyz(1,n) = xs+fxa*(xe-xs) 149 | pxyz(2,n) = yt(1) 150 | call random_number(fxa) 151 | pxyz(3,n) = zs+fxa*(ze-zs) 152 | enddo 153 | 154 | !call allocate_particles(2) 155 | !pxyz(:,1) = (/10.d0 , yt(js_pe), -8.d0/) 156 | !pxyz(:,2) = (/14.d0 , yt(js_pe), -8.d0/) 157 | 158 | end subroutine set_particles 159 | -------------------------------------------------------------------------------- /for_config/overflow1.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | !======================================================================= 5 | ! 6 | ! slope convection 7 | ! 8 | !======================================================================= 9 | 10 | module config_module 11 | real*8 :: fac=1.0,mix=5e-3,L0,H0 12 | end module config_module 13 | 14 | subroutine set_parameter 15 | use main_module 16 | use config_module 17 | use diagnostics_module 18 | use tke_module 19 | implicit none 20 | 21 | nx=int(128*fac) 22 | nz=int(40*fac) 23 | ny=1 24 | dt_tracer=0.25/fac 25 | dt_mom =0.25/fac 26 | 27 | enable_conserve_energy = .false. 28 | coord_degree = .false. 29 | enable_hydrostatic = .false. 30 | 31 | eq_of_state_type = 1 32 | 33 | congr_epsilon = 1e-6 34 | congr_max_iterations = 5000 35 | congr_epsilon_non_hydro= 1e-6 36 | congr_max_itts_non_hydro = 5000 37 | 38 | enable_explicit_vert_friction = .true. 39 | kappam_0 = mix/fac**2 40 | enable_hor_friction = .true. 41 | a_h = mix/fac**2 42 | 43 | enable_superbee_advection = .true. 44 | !enable_hor_diffusion = .true 45 | !kappah_0 = mix/fac**2 46 | !k_h = mix/fac**2 47 | 48 | runlen = 86400.0 49 | enable_diag_ts_monitor = .true.; ts_monint =dt_tracer 50 | enable_diag_snapshots = .true.; snapint = 20 51 | end subroutine set_parameter 52 | 53 | 54 | subroutine set_grid 55 | use main_module 56 | use config_module 57 | implicit none 58 | dxt(:)=0.5/fac 59 | dyt(:)=0.5/fac 60 | dzt(:)=0.5/fac 61 | L0 = dxt(is_pe)*nx 62 | H0 = dzt(1)*nz 63 | end subroutine set_grid 64 | 65 | subroutine set_coriolis 66 | end subroutine set_coriolis 67 | 68 | 69 | 70 | subroutine set_initial_conditions 71 | use main_module 72 | use config_module 73 | implicit none 74 | integer :: i 75 | temp = 0.5 76 | do i=is_pe-onx,ie_pe+onx 77 | if (xt(i) <= L0/3) temp(i,:,:,:)=0 78 | enddo 79 | end subroutine set_initial_conditions 80 | 81 | 82 | 83 | 84 | subroutine set_forcing 85 | end subroutine set_forcing 86 | 87 | 88 | subroutine set_topography 89 | use main_module 90 | use config_module 91 | implicit none 92 | integer :: i,k 93 | real*8 :: fxa 94 | kbot =1 95 | do i=is_pe,ie_pe 96 | fxa=H0-H0/2*exp( -(xt(i)-L0/3)**2/(L0/4.)**2) 97 | do k=1,nz 98 | if (zt(k).lt.-fxa) kbot(i,:)=k 99 | enddo 100 | enddo 101 | end subroutine set_topography 102 | 103 | 104 | subroutine set_diagnostics 105 | end subroutine set_diagnostics 106 | 107 | 108 | subroutine set_particles 109 | end subroutine set_particles 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /for_config/overflow1_3D.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | !======================================================================= 4 | ! 3D slope convection 5 | !======================================================================= 6 | 7 | module config_module 8 | real*8 :: fac=2.0,mix=2e-06,L0,H0,B0 9 | real*8, allocatable :: T0(:,:,:) 10 | end module config_module 11 | 12 | subroutine set_parameter 13 | use main_module 14 | use config_module 15 | use diagnostics_module 16 | use tke_module 17 | implicit none 18 | nx=int(60*fac) 19 | nz=int(20*fac) 20 | ny=int(60*fac) 21 | 22 | dt_tracer=0.25/fac 23 | dt_mom =0.25/fac 24 | 25 | enable_conserve_energy = .false. 26 | coord_degree = .false. 27 | enable_hydrostatic = .false. 28 | 29 | eq_of_state_type = 1 30 | 31 | congr_epsilon = 1e-8 32 | congr_max_iterations = 5000 33 | congr_epsilon_non_hydro= 1e-8 34 | congr_max_itts_non_hydro = 5000 35 | 36 | enable_bottom_friction = .true. 37 | r_bot = 0.7 38 | 39 | enable_explicit_vert_friction = .true. 40 | kappam_0 = mix/fac**2 41 | !vertikale reibung 42 | enable_hor_friction = .true. 43 | a_h = mix/fac**2 44 | !horizontale reibung 45 | 46 | enable_superbee_advection = .true. 47 | !enable_hor_diffusion = .true 48 | !kappah_0 = mix/fac**2 49 | !k_h = mix/fac**2 50 | 51 | !enable_tempsalt_sources = .true. ! restoring zone 52 | 53 | 54 | runlen = 86400 55 | enable_diag_ts_monitor = .true.; ts_monint =dt_tracer 56 | enable_diag_snapshots = .true.; snapint = 1 57 | end subroutine set_parameter 58 | 59 | 60 | subroutine set_grid 61 | use main_module 62 | use config_module 63 | implicit none 64 | dxt(:)=0.01/fac 65 | dyt(:)=0.01/fac 66 | dzt(:)=0.01/fac 67 | 68 | L0 = dxt(is_pe)*nx !länge tank 69 | H0 = dzt(1)*nz !höhe tank 70 | B0 = dyt(js_pe)*ny !breite tank 71 | end subroutine set_grid 72 | 73 | subroutine set_coriolis 74 | use main_module 75 | implicit none 76 | !coriolis_t = 0.1047 !1rpm 77 | !coriolis_t = 0.2094 !2rpm 78 | coriolis_t = 0.4189 !4rpm 79 | !coriolis_t = 0.8378 !8rpm 80 | end subroutine set_coriolis 81 | 82 | 83 | 84 | subroutine set_initial_conditions 85 | use main_module 86 | use config_module 87 | implicit none 88 | integer :: i,slope 89 | real*8 :: temp_shelf,shelf 90 | 91 | allocate( T0(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); T0=0.0 92 | slope = nx/4 !Wo soll der Hang beginnen? Muss Integer sein! 93 | shelf = H0/4 !Wie tief soll das Schelf sein? 94 | temp_shelf = 10 95 | T0 = 12 96 | do i=is_pe-onx,ie_pe+onx 97 | if (i<=slope) T0(i,:,:)=temp_shelf 98 | enddo 99 | temp(:,:,:,taum1) = T0 100 | temp(:,:,:,tau) = T0 101 | end subroutine set_initial_conditions 102 | 103 | 104 | subroutine set_forcing 105 | use main_module 106 | use config_module 107 | implicit none 108 | integer :: i 109 | !if (enable_tempsalt_sources) then 110 | ! do i=1,nx/4 111 | ! if (i>=is_pe.and.i<=ie_pe) temp_source(i,:,:)=maskT(i,:,:)*(T0(i,:,:)-temp(i,:,:,taum1))/(dt_mom*10) 112 | ! enddo 113 | !endif 114 | end subroutine set_forcing 115 | 116 | 117 | 118 | 119 | subroutine set_topography 120 | use main_module 121 | use config_module 122 | implicit none 123 | integer :: i,k,j,slope 124 | real*8 :: fxa,shelf,gap1,gap2,a,b 125 | kbot =1 126 | 127 | slope = nx/4 !Wo soll der Hang beginnen? Muss Integer sein! 128 | shelf = H0/4 !Wie tief soll das Schelf sein? 129 | gap1 = nx*2/3 !Wo soll die Lücke in der Barriere beginnen? 130 | gap2 = nx*5/6 !Wo soll sie enden? 131 | b=(nx*shelf-H0*slope)/(nx-slope) 132 | a=(shelf-b)/slope 133 | 134 | do i=is_pe,ie_pe 135 | if (i<=slope) fxa=shelf 136 | if (i>slope) fxa=a*i+b 137 | do k=1,nz 138 | if (zt(k).lt.-fxa) kbot(i,:)=k 139 | enddo 140 | if (i == slope) then 141 | do j=js_pe,je_pe 142 | if (jgap2) then 146 | kbot(i,j)=0 147 | endif 148 | enddo 149 | end if 150 | enddo 151 | end subroutine set_topography 152 | 153 | subroutine set_diagnostics 154 | end subroutine set_diagnostics 155 | 156 | subroutine set_particles 157 | end subroutine set_particles 158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /for_config/rayleigh1.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | !======================================================================= 5 | ! Rayleigh Bernard convection 6 | !======================================================================= 7 | 8 | module config_module 9 | real*8 :: fac=2.0,mix=5e-3 10 | end module config_module 11 | 12 | subroutine set_parameter 13 | use main_module 14 | use config_module 15 | use diagnostics_module 16 | implicit none 17 | 18 | nx=int(64*fac) 19 | nz=int(20*fac) 20 | ny=1 21 | dt_tracer=0.25/fac 22 | dt_mom =0.25/fac 23 | 24 | enable_conserve_energy = .false. 25 | coord_degree = .false. 26 | enable_cyclic_x = .true. 27 | enable_hydrostatic = .false. 28 | 29 | eq_of_state_type = 1 30 | enable_tempsalt_sources = .true. 31 | 32 | congr_epsilon = 1e-6 33 | congr_max_iterations = 5000 34 | congr_epsilon_non_hydro= 1e-6 35 | congr_max_itts_non_hydro = 5000 36 | 37 | enable_explicit_vert_friction = .true. 38 | kappam_0 = mix/fac**2 39 | enable_hor_friction = .true. 40 | a_h = mix/fac**2 41 | 42 | enable_superbee_advection = .true. 43 | !enable_hor_diffusion = .true 44 | !kappah_0 = mix/fac**2 45 | !k_h = mix/fac**2 46 | 47 | runlen = 86400.0 48 | enable_diag_ts_monitor = .true.; ts_monint =dt_tracer 49 | enable_diag_snapshots = .true.; snapint = 20 50 | end subroutine set_parameter 51 | 52 | 53 | subroutine set_grid 54 | use main_module 55 | use config_module 56 | implicit none 57 | dxt(:)=0.5/fac 58 | dyt(:)=0.5/fac 59 | dzt(:)=0.5/fac 60 | end subroutine set_grid 61 | 62 | subroutine set_coriolis 63 | end subroutine set_coriolis 64 | 65 | 66 | 67 | subroutine set_initial_conditions 68 | use main_module 69 | implicit none 70 | integer :: i,j,k 71 | do k=1,nz 72 | do j=js_pe-onx,je_pe+onx 73 | do i=is_pe-onx,ie_pe+onx 74 | temp(i,j,k,:)= 0.05*sin(xt(i)/(20*dxt(is_pe))*pi)*maskT(i,j,k) 75 | enddo 76 | enddo 77 | enddo 78 | end subroutine set_initial_conditions 79 | 80 | 81 | 82 | 83 | subroutine set_forcing 84 | use main_module 85 | implicit none 86 | temp_source(:,:,nz) = -175/4185.5 /dzt(nz) 87 | temp_source(:,:,1 ) = 175/4185.5 /dzt(1) 88 | end subroutine set_forcing 89 | 90 | 91 | subroutine set_topography 92 | use main_module 93 | implicit none 94 | kbot =1 95 | end subroutine set_topography 96 | 97 | 98 | subroutine set_diagnostics 99 | end subroutine set_diagnostics 100 | 101 | 102 | subroutine set_particles 103 | end subroutine set_particles 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /for_config/rayleigh2.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | !======================================================================= 5 | ! Rayleigh Bernard convection 6 | !======================================================================= 7 | 8 | module config_module 9 | real*8 :: fac=1.0,mix=5e-6 !fac was 2, mix was e-4 10 | real*8, allocatable :: heat_flux(:,:) 11 | end module config_module 12 | 13 | subroutine set_parameter 14 | use main_module 15 | use config_module 16 | use diagnostics_module 17 | use tke_module 18 | implicit none 19 | 20 | nx=int(160*fac) !was 64* 21 | nz=int(60*fac) 22 | ny=1 23 | dt_tracer=0.1!0.01/fac 24 | dt_mom =dt_tracer !0.01/fac 25 | 26 | enable_conserve_energy = .false. 27 | coord_degree = .false. 28 | enable_cyclic_x = .true. 29 | enable_hydrostatic = .false. 30 | 31 | eq_of_state_type = 1 32 | enable_tempsalt_sources = .true. 33 | 34 | congr_epsilon = 1e-9 35 | congr_max_iterations = 5000 36 | congr_epsilon_non_hydro= 1e-9 37 | congr_max_itts_non_hydro = 5000 38 | 39 | enable_explicit_vert_friction = .true. 40 | kappam_0 = mix/fac**2 41 | enable_hor_friction = .true. 42 | a_h = mix/fac**2 43 | 44 | enable_superbee_advection = .true. 45 | !enable_hor_diffusion = .true 46 | !kappah_0 = mix/fac**2 47 | !k_h = mix/fac**2 48 | 49 | runlen = 86400.0 50 | enable_diag_ts_monitor = .true.; ts_monint =dt_tracer 51 | enable_diag_snapshots = .true.; snapint = 1 !change this for ocean vs.tank 52 | end subroutine set_parameter 53 | 54 | 55 | subroutine set_grid 56 | use main_module 57 | use config_module 58 | implicit none 59 | dxt(:)=0.005/fac 60 | dyt(:)=0.005/fac 61 | dzt(:)=0.005/fac 62 | end subroutine set_grid 63 | 64 | subroutine set_coriolis 65 | end subroutine set_coriolis 66 | 67 | 68 | 69 | subroutine set_initial_conditions 70 | use main_module 71 | use config_module 72 | implicit none 73 | integer :: i,k 74 | !temp(0:160,ny,40:60,:) = 5 !was temp(:,:,:,:)=0 75 | do k=40,60 76 | do i=1,160 77 | if (i>=is_pe.and.i<=ie_pe) temp(i,:,k,:) = 5 78 | enddo 79 | enddo 80 | 81 | allocate( heat_flux(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); heat_flux = 0 82 | do i=nx/2-3,nx/2+3 83 | if (i>=is_pe.and.i<=ie_pe) heat_flux(i,:) = 5/4185.5/dzt(1) 84 | enddo 85 | 86 | end subroutine set_initial_conditions 87 | 88 | 89 | 90 | 91 | subroutine set_forcing 92 | use main_module 93 | use config_module 94 | implicit none 95 | !temp_source((nx/2 -3):(nx/2 +3),:,4) = 5/4185.5 /dzt(1) !was temp_source(:,:,1) 96 | temp_source(:,:,4) = heat_flux 97 | end subroutine set_forcing 98 | 99 | 100 | subroutine set_topography 101 | use main_module 102 | implicit none 103 | kbot =1 104 | end subroutine set_topography 105 | 106 | 107 | subroutine set_diagnostics 108 | end subroutine set_diagnostics 109 | 110 | 111 | subroutine set_particles 112 | end subroutine set_particles 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /for_config/saturn1.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! 4 | !======================================================================= 5 | 6 | module config_module 7 | implicit none 8 | real*8, allocatable :: U_0(:,:,:),T_0(:,:,:) 9 | real*8,parameter :: Ek = 0.01 10 | real*8,parameter :: deg_wide = 20. 11 | real*8,parameter :: delta_x = 0.25 12 | real*8,parameter :: H0 = 2000.0 13 | real*8,parameter :: N0 = 40*1e-4 14 | real*8,parameter :: U0 = 0.5 15 | real*8,parameter :: M0 = sqrt(1e-4*U0/H0) 16 | real*8,parameter :: CFL = 0.01 17 | end module config_module 18 | 19 | 20 | subroutine set_parameter 21 | ! ---------------------------------- 22 | ! set here main parameter 23 | ! ---------------------------------- 24 | use main_module 25 | use diagnostics_module 26 | use config_module 27 | implicit none 28 | 29 | nx = int(deg_wide/delta_x*2); nz = 10.; ny = nx 30 | 31 | coord_degree = .true. 32 | congr_epsilon = 1e-12 33 | congr_max_iterations = 5000 34 | enable_free_surface = .true. 35 | 36 | enable_hydrostatic = .true. 37 | enable_cyclic_x = .true. 38 | enable_cyclic_y = .true. 39 | 40 | enable_superbee_advection = .true. 41 | enable_explicit_vert_friction = .true. 42 | enable_biharmonic_friction = .true. 43 | 44 | enable_conserve_energy = .false. 45 | 46 | runlen = 365*86400.*100 47 | 48 | enable_diag_ts_monitor = .true.; ts_monint = 86400. 49 | enable_diag_snapshots = .true.; snapint = 86400. 50 | 51 | eq_of_state_type = 1 52 | 53 | enable_tempsalt_sources = .true. 54 | 55 | end subroutine set_parameter 56 | 57 | 58 | subroutine set_grid 59 | use main_module 60 | use config_module 61 | implicit none 62 | dzt = H0/nz 63 | dxt = delta_x 64 | dyt = delta_x 65 | x_origin= -deg_wide 66 | y_origin= -deg_wide 67 | 68 | a_hbi = Ek*2*omega*dxt(is_pe)**4 69 | kappam_0 = Ek*2*omega*dzt(1)**2 70 | 71 | dt_mom = CFL/U0*dxt(is_pe)*degtom 72 | dt_tracer = dt_mom 73 | end subroutine set_grid 74 | 75 | 76 | subroutine set_coriolis 77 | use main_module 78 | implicit none 79 | integer :: i,j 80 | do j=js_pe-onx,je_pe+onx 81 | do i=is_pe-onx,ie_pe+onx 82 | coriolis_t(i,j) = 2*omega*cos( yt(j)/180.*pi )*cos( xt(i)/180.*pi ) 83 | enddo 84 | enddo 85 | end subroutine set_coriolis 86 | 87 | 88 | subroutine set_initial_conditions 89 | use main_module 90 | use config_module 91 | 92 | 93 | implicit none 94 | 95 | integer :: k,j,i 96 | real*8 :: alpha,get_drhodT,fxa 97 | real*8 :: Ly 98 | 99 | if (my_pe==0) then 100 | print*,' Rossby radius ', N0*H0/coriolis_t(is_pe,js_pe) /1e3,' km' 101 | print*,' delta x ', dxt(is_pe)/1e3,'km' 102 | print*,' delta t ', dt_mom,'s' 103 | endif 104 | 105 | alpha = get_drhodT(35d0,5d0,0d0) 106 | 107 | allocate( U_0(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ) 108 | allocate( T_0(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ) 109 | U_0 = 0; T_0 = 0 110 | 111 | ! zonal velocity 112 | do k=1,nz 113 | U_0(:,:,k)= 0. 114 | u(:,:,k,tau)= U_0(:,:,k) 115 | enddo 116 | u(:,:,:,taum1) = u(:,:,:,tau) 117 | 118 | 119 | do k=1,nz 120 | T_0(:,:,k)=-N0**2*zt(k)/grav/alpha*rho_0*maskT(:,:,k) 121 | enddo 122 | 123 | Ly = nx*dyt(js_pe) 124 | fxa = M0**2*Ly/grav/alpha*rho_0 125 | do j=js_pe,je_pe 126 | do i=is_pe,ie_pe 127 | T_0(i,j,:) = T_0(i,j,:) - fxa*exp(-(yt(j)**2+xt(i)**2)/(0.5*deg_wide)**2) 128 | enddo 129 | enddo 130 | 131 | do k=1,nz 132 | temp(:,:,k,tau) = T_0(:,:,k) 133 | temp(:,:,k,taum1) = T_0(:,:,k) 134 | enddo 135 | 136 | end subroutine set_initial_conditions 137 | 138 | 139 | 140 | subroutine set_forcing 141 | 142 | end subroutine set_forcing 143 | 144 | 145 | 146 | subroutine set_topography 147 | use main_module 148 | implicit none 149 | kbot=1 150 | end subroutine set_topography 151 | 152 | subroutine set_diagnostics 153 | end subroutine set_diagnostics 154 | 155 | subroutine set_particles 156 | end subroutine set_particles 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /for_config/shear1.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! Kelvin Helmholtz instability 4 | !======================================================================= 5 | 6 | 7 | 8 | subroutine set_parameter 9 | use main_module 10 | use diagnostics_module 11 | implicit none 12 | 13 | nx=64;ny=1;nz=nx 14 | 15 | dt_mom=0.1 16 | dt_tracer = dt_mom 17 | 18 | enable_conserve_energy = .false. 19 | coord_degree =.false. 20 | enable_cyclic_x =.true. 21 | enable_cyclic_y =.true. 22 | enable_hydrostatic =.false. 23 | eq_of_state_type = 1 24 | 25 | congr_epsilon = 1d-6 26 | congr_epsilon_non_hydro= 1d-4 27 | 28 | 29 | enable_explicit_vert_friction = .true.; 30 | enable_hor_friction = .true.; 31 | enable_hor_diffusion = .true.; 32 | 33 | A_h = 1e-3 34 | K_h = A_h 35 | kappaM_0 = A_h 36 | kappaH_0 = A_h 37 | 38 | 39 | 40 | 41 | enable_diag_snapshots = .true.; snapint = 5.0 42 | enable_diag_ts_monitor = .true.; ts_monint = snapint 43 | snapint = 5.0 !dt*10 44 | runlen = snapint*400 45 | 46 | end subroutine set_parameter 47 | 48 | 49 | subroutine set_grid 50 | use main_module 51 | 52 | implicit none 53 | dxt(:)=0.25 54 | dyt(:)=0.25 55 | dzt(:)=0.25 56 | end subroutine set_grid 57 | 58 | subroutine set_coriolis 59 | end subroutine set_coriolis 60 | 61 | 62 | 63 | 64 | 65 | subroutine set_initial_conditions 66 | use main_module 67 | implicit none 68 | integer :: i,j,k 69 | real*8 :: Lx,z0,z1 70 | 71 | Lx = nx*dxt(is_pe) 72 | z0 = zt(nz/2) 73 | z1 = 0.25/2. 74 | do k=1,nz 75 | do j=js_pe,je_pe 76 | do i=is_pe-onx,ie_pe+onx 77 | u(i,j,k,tau) = 0.6+0.5*tanh( (zt(k)-z0)/z1) 78 | temp(i,j,k,tau) = 10*(1+tanh( (zt(k)-z0)/z1) +0.2*sin( xt(i)/Lx*12*pi) ) 79 | enddo 80 | enddo 81 | enddo 82 | 83 | end subroutine set_initial_conditions 84 | 85 | 86 | 87 | 88 | subroutine set_forcing 89 | 90 | end subroutine set_forcing 91 | 92 | 93 | 94 | subroutine set_topography 95 | use main_module 96 | implicit none 97 | kbot =1 98 | end subroutine set_topography 99 | 100 | 101 | subroutine set_diagnostics 102 | end subroutine set_diagnostics 103 | 104 | 105 | subroutine set_particles 106 | end subroutine set_particles 107 | -------------------------------------------------------------------------------- /for_config/test_adv1.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! idealised Southern Ocean, same as in Viebahn and Eden (2010) Ocean modeling 4 | !======================================================================= 5 | 6 | 7 | module config_module 8 | ! use this module only locally in this file 9 | implicit none 10 | real*8,parameter :: hRESOLVE = 0.5 ! 1 in original model 11 | real*8 :: L_y,L_x 12 | real*8 :: t_rest=30*86400 13 | real*8:: phi0 = 30.0 /180. *3.1415 14 | end module config_module 15 | 16 | 17 | subroutine set_parameter 18 | ! ---------------------------------- 19 | ! set here main parameter 20 | ! ---------------------------------- 21 | use main_module 22 | use config_module 23 | use diagnostics_module 24 | 25 | implicit none 26 | nx = int( 64*hRESOLVE ); nz = 3; ny = int( 64*hRESOLVE ) 27 | dt_mom = 200.0/hRESOLVE 28 | dt_tracer = 200.0/hRESOLVE !*5 29 | 30 | coord_degree = .false. 31 | enable_cyclic_x = .true. 32 | enable_hydrostatic = .true. 33 | eq_of_state_type = 1 34 | 35 | congr_epsilon = 1e-6 36 | congr_max_iterations = 5000 37 | enable_streamfunction = .true. 38 | 39 | !enable_upwind3_advection = .true. 40 | enable_dst3_advection = .true. 41 | !enable_superbee_advection = .true. 42 | enable_AB_time_stepping = .false. 43 | enable_momentum_equation = .false. 44 | 45 | !kappah_0=1.e-4/vRESOLVE 46 | !kappam_0=1.e-3/vRESOLVE 47 | enable_conserve_energy = .false. 48 | runlen = 365*86400.*0.5 49 | enable_diag_ts_monitor = .true.; ts_monint = dt_tracer 50 | enable_diag_snapshots = .true.; snapint = 86400./20. 51 | end subroutine set_parameter 52 | 53 | 54 | 55 | subroutine set_grid 56 | use main_module 57 | use config_module 58 | implicit none 59 | dxt = 5e3/hRESOLVE 60 | dyt = 5e3/hRESOLVE 61 | dzt = 100.0!/vRESOLVE 62 | end subroutine set_grid 63 | 64 | subroutine set_coriolis 65 | end subroutine set_coriolis 66 | 67 | 68 | subroutine set_initial_conditions 69 | use main_module 70 | use tke_module 71 | use idemix_module 72 | use config_module 73 | use obc_module 74 | implicit none 75 | integer :: i,j,k 76 | real*8 :: alpha,get_drhodT,L_R,k0 77 | 78 | salt = 35.0 79 | temp = 0.0 80 | u(:,:,:,1)=10*maskU 81 | u(:,:,:,2)=10*maskU 82 | u(:,:,:,3)=10*maskU 83 | 84 | alpha = get_drhodT(35d0,0d0,0d0) 85 | L_R = 25e3!(nz*dzt(1)*N_0)/(pi*coriolis_t(i,j) ) 86 | k0 = 2*2*pi/(nx*dxt(is_pe)) 87 | do k=1,nz 88 | do j=js_pe-onx,je_pe+onx 89 | do i=is_pe-onx,ie_pe+onx 90 | !temp(i,j,k,:) =exp(-(xt(i)-L_x/2.)**2/L_R**2-(yt(j)-L_y/2.)**2/L_R**2)*maskT(i,j,k) 91 | temp(i,j,k,:) =sin(xt(i)*k0)*maskT(i,j,k) 92 | enddo 93 | enddo 94 | enddo 95 | 96 | end subroutine set_initial_conditions 97 | 98 | 99 | 100 | subroutine set_forcing 101 | end subroutine set_forcing 102 | 103 | subroutine set_topography 104 | use main_module 105 | use config_module 106 | implicit none 107 | 108 | L_y = 0.0; if (my_blk_j == n_pes_j) L_y = yu(ny) 109 | call global_max(L_y) 110 | L_x = 0.0; if (my_blk_i == n_pes_i) L_x = xu(nx) 111 | call global_max(L_x) 112 | if (my_pe==0) print*,' domain size is ',L_x,' m x ',L_y,' m' 113 | 114 | kbot=1 115 | end subroutine set_topography 116 | 117 | 118 | 119 | 120 | subroutine set_diagnostics 121 | end subroutine set_diagnostics 122 | 123 | subroutine set_particles 124 | end subroutine set_particles 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /for_config/test_bihathk1.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! test for isopycnal mixing 4 | !======================================================================= 5 | module config_module 6 | ! use this module only locally in this file 7 | implicit none 8 | real*8 :: Ly=1000e3,Lz = 2000. ,f0 = 1e-4 ,N0=30e-4 9 | end module config_module 10 | 11 | 12 | subroutine set_parameter 13 | ! ---------------------------------- 14 | ! set here main parameter 15 | ! ---------------------------------- 16 | use main_module 17 | use isoneutral_module 18 | use biharmonic_thickness_module 19 | use diagnostics_module 20 | use config_module 21 | implicit none 22 | 23 | nx = 1; nz = 40; ny = 30 24 | dt_mom = 1200 25 | dt_tracer = dt_mom 26 | 27 | coord_degree = .false. 28 | eq_of_state_type = 5 29 | enable_hydrostatic = .true. 30 | enable_cyclic_x = .true. 31 | 32 | congr_epsilon = 1e-8 33 | congr_max_iterations = 5000 34 | 35 | runlen = dt_mom*1000000 !365*86400.*2000 36 | 37 | enable_diag_ts_monitor = .true.; ts_monint = dt_mom!/12. 38 | enable_diag_snapshots = .true.; snapint = 86400.!*30 39 | !enable_diag_tracer_content = .true.; trac_cont_int=dt_mom 40 | 41 | 42 | enable_conserve_energy = .true. 43 | enable_store_lateral_friction_heat = .true. 44 | 45 | enable_superbee_advection = .true. 46 | 47 | 48 | !enable_neutral_diffusion = .true.; 49 | K_iso_0 = 00.0 50 | K_iso_steep = 00.0 51 | iso_dslope=0.002 52 | iso_slopec=0.01 53 | K_gm_0 = 2000.0 54 | enable_skew_diffusion = .true. 55 | 56 | enable_biharmonic_friction = .true. 57 | A_hbi = 1e12 58 | 59 | 60 | enable_biharmonic_thickness_bolus_skew = .true. 61 | A_thkbi = A_hbi 62 | mld0_thk = 0. 63 | biha_dslope=1d-12 64 | biha_slopec=4d-12 65 | 66 | !enable_biharmonic_thickness_backscatter_skew = .true. 67 | !biharmonic_thickness_backscatter_smooth = 1 68 | !A_thk_0 = -200.0 69 | !enable_biharmonic_thickness_backscatter_integrate_energy = .true. 70 | 71 | !enable_biharmonic_thickness_explicit = .true. 72 | !A_thkbi = A_hbi 73 | !biharmonic_thickness_mixing_iter = 30 74 | 75 | end subroutine set_parameter 76 | 77 | 78 | 79 | subroutine set_grid 80 | use main_module 81 | use config_module 82 | implicit none 83 | dyt = Ly/ny 84 | dxt = dyt(js_pe) 85 | dzt = Lz/nz 86 | 87 | end subroutine set_grid 88 | 89 | 90 | subroutine set_coriolis 91 | use main_module 92 | use config_module 93 | implicit none 94 | coriolis_t = f0 95 | end subroutine set_coriolis 96 | 97 | 98 | subroutine set_initial_conditions 99 | use main_module 100 | use config_module 101 | implicit none 102 | integer :: i,j,k 103 | real*8 :: y,alpha,get_drhodT 104 | 105 | 106 | alpha = get_drhodT(35d0,5d0,0d0) 107 | do k=1,nz 108 | do j=js_pe-onx,je_pe+onx 109 | do i=is_pe-onx,ie_pe+onx 110 | y = yt(j)/Ly 111 | salt(i,j,k,:) = 35 112 | temp(i,j,k,:) = 20-N0**2*zt(k)/grav/alpha*rho_0 + 2*(tanh((y-0.5)*20)+1.0) 113 | enddo 114 | enddo 115 | enddo 116 | temp(:,:,nz,:) = temp(:,:,nz-3,:) 117 | temp(:,:,nz-1,:) = temp(:,:,nz-3,:) 118 | temp(:,:,nz-2,:) = temp(:,:,nz-3,:) 119 | 120 | end subroutine set_initial_conditions 121 | 122 | subroutine set_momentum_forcing 123 | end subroutine set_momentum_forcing 124 | 125 | subroutine set_forcing 126 | end subroutine set_forcing 127 | 128 | subroutine set_topography 129 | use main_module 130 | implicit none 131 | !integer :: j 132 | kbot=1 133 | 134 | !do j=js_pe-onx,je_pe+onx 135 | ! if (j>=ny/4.and.j<=3*ny/4) kbot(:,j) = nz/5 136 | !enddo 137 | end subroutine set_topography 138 | 139 | subroutine set_diagnostics 140 | end subroutine set_diagnostics 141 | 142 | subroutine set_particles 143 | end subroutine set_particles -------------------------------------------------------------------------------- /for_config/test_idemix1.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! 1 D test case for idemix and tke model 4 | !======================================================================= 5 | 6 | module config_module 7 | ! use this module only locally in this file 8 | implicit none 9 | real*8,parameter :: N_0 = 0.008, z_b = 800.0 ! N=N_0 exp(z/z_b) 10 | real*8, parameter :: U00 = 0.5,V00 = 0.0, zu0=200.0,zu1=500, zu2 = 1200 11 | real*8, allocatable :: u_ini(:,:,:),v_ini(:,:,:) 12 | end module config_module 13 | 14 | 15 | subroutine set_parameter 16 | ! ---------------------------------- 17 | ! set here main parameter 18 | ! ---------------------------------- 19 | use main_module 20 | use config_module 21 | use diagnostics_module 22 | use tke_module 23 | use idemix_module 24 | 25 | implicit none 26 | !nx = 1; nz = 200; ny = 1 27 | nx = 1; nz = 50; ny = 1 28 | dt_mom = 360 29 | dt_tracer = dt_mom 30 | 31 | coord_degree = .false. 32 | enable_cyclic_x = .true. 33 | enable_cyclic_y = .true. 34 | enable_hydrostatic = .true. 35 | eq_of_state_type = 5 ! 5???? 36 | 37 | !enable_momentum_equation = .false. 38 | enable_thermodynamic_equation = .false. 39 | 40 | congr_epsilon = 1e-12 41 | congr_max_iterations = 5000 42 | !enable_streamfunction = .true. 43 | 44 | runlen = 365*86400.*10 45 | enable_diag_ts_monitor = .true.; ts_monint = dt_tracer 46 | enable_diag_snapshots = .true.; snapint = 3600. 47 | enable_diag_energy = .true.; energint = snapint; energfreq = dt_tracer 48 | 49 | !enable_conserve_energy = .false. 50 | enable_store_cabbeling_heat = .true. 51 | enable_store_bottom_friction_tke = .true. 52 | 53 | enable_momentum_sources_with_AB = .true. 54 | 55 | enable_implicit_vert_friction = .true.; 56 | enable_tke = .true. 57 | 58 | enable_idemix = .true. 59 | enable_idemix3 = .true. 60 | tau_v = 3*86400. 61 | mu0 = 4./3. 62 | mu0_min = 0. 63 | tc_max = 1e-3 64 | Noverf_min0 = 0. 65 | !AB_eps = 0.03 66 | 67 | idemix3_leewaves_intervall = dt_tracer 68 | enable_leewaves = .true. 69 | nk = 32 70 | nph = 32 71 | 72 | end subroutine set_parameter 73 | 74 | 75 | 76 | subroutine set_grid 77 | use main_module 78 | use config_module 79 | implicit none 80 | dxt = 5e3 81 | dyt = 5e3 82 | dzt = 2000./nz !10.0 83 | end subroutine set_grid 84 | 85 | subroutine set_coriolis 86 | use main_module 87 | use config_module 88 | implicit none 89 | coriolis_t = 2*omega*sin(30.0 /180.*pi) 90 | end subroutine set_coriolis 91 | 92 | 93 | subroutine set_initial_conditions 94 | use main_module 95 | use tke_module 96 | use idemix_module 97 | use config_module 98 | implicit none 99 | integer :: i,j,k 100 | real*8 :: alpha,get_drhodT,N2 101 | 102 | 103 | allocate( u_ini(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); u_ini=0. 104 | allocate( v_ini(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); v_ini=0. 105 | 106 | salt = 35.0 107 | temp(:,:,nz,:)=25d0 108 | do k=nz-1,1,-1 109 | do j=js_pe-onx,je_pe+onx 110 | do i=is_pe-onx,ie_pe+onx ! b_z=N^2 , b=-rho/rho_0 g, T=rho/rho_T, T=-b rho_0/( rho_T g) 111 | alpha = get_drhodT(salt(i,j,k,1),temp(i,j,k+1,1),abs(zt(k))) 112 | N2 = ( N_0*exp(zt(k)/z_b) )**2 113 | temp(i,j,k,:) = ( temp(i,j,k+1,:) +dzw(k)*rho_0/(grav*alpha)*N2 )*maskT(i,j,k) 114 | enddo 115 | enddo 116 | enddo 117 | 118 | do k=1,nz 119 | u_ini(:,:,k) = 0.1*(1-tanh( (zt(k)+zu1)/zu0)) 120 | !v_ini(:,:,k) = V00*tanh( (zt(k)+zu1)/zu0) 121 | !u_ini(:,:,k) = 0.1+U00*exp( -(zt(k)+zu1)**2/zu0**2) 122 | !v_ini(:,:,k) = V00*exp( -(zt(k)+zu1)**2/zu0**2) 123 | enddo 124 | 125 | u(:,:,:,tau) = u_ini 126 | v(:,:,:,tau) = v_ini 127 | u(:,:,:,taum1) = u_ini 128 | v(:,:,:,taum1) = v_ini 129 | u(:,:,:,taup1) = u_ini 130 | v(:,:,:,taup1) = v_ini 131 | 132 | if (enable_idemix ) then 133 | !do k=1,nz 134 | ! E_iw(:,:,k,:) = 1e-3*exp( -(zt(k)-zt(nz/2))**2/200.0**2) 135 | !enddo 136 | if (enable_idemix3 ) then 137 | ! E+ = 0.5(E_s+E_d) 138 | ! E- = 0.5(E_s-E_d) 139 | 140 | do k=1,nz 141 | ! F_s(:,:,k,:) = 1e-3*exp( -(zt(k)+1200)**2/200.0**2) 142 | ! G_s(:,:,k,:) = .1e-3*exp( -(zt(k)+1200)**2/200.0**2) 143 | enddo 144 | !forc_iw_bottom_u = 0.5e-6 145 | !forc_iw_bottom_v = 0.5e-6 146 | !forc_iw_surface_u = 0.5e-6 147 | !forc_iw_surface_v = 0.5e-6 148 | !forc_iw_surface = 2*.5e-6 149 | 150 | if (enable_leewaves) then 151 | h_rms = 50. 152 | ph_s = 0 153 | k_s = 2*sqrt(2*(nu+0.5))/20e3 154 | k_n = k_s 155 | else 156 | forc_iw_bottom_u = 1.5e-5 157 | forc_iw_bottom_v = 1.5e-5 158 | endif 159 | 160 | else 161 | forc_iw_bottom = 2*0.5e-6 162 | endif 163 | endif 164 | 165 | end subroutine set_initial_conditions 166 | 167 | 168 | subroutine set_forcing 169 | ! u_t = f v - f v* + Fu_z 170 | ! v_t = - f u + f u* + Fv_z 171 | use main_module 172 | use config_module 173 | implicit none 174 | integer :: k 175 | do k=1,nz 176 | u_source(:,:,k) = -coriolis_t(:,:)*v_ini(:,:,k) 177 | v_source(:,:,k) = coriolis_t(:,:)*u_ini(:,:,k) 178 | enddo 179 | end subroutine set_forcing 180 | 181 | subroutine set_topography 182 | use main_module 183 | implicit none 184 | kbot=1 185 | end subroutine set_topography 186 | 187 | 188 | subroutine set_diagnostics 189 | end subroutine set_diagnostics 190 | 191 | subroutine set_particles 192 | end subroutine set_particles 193 | 194 | 195 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /for_config/test_idemix2.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! 2 D test case for idemix and tke model 4 | !======================================================================= 5 | 6 | module config_module 7 | ! use this module only locally in this file 8 | implicit none 9 | real*8,parameter :: N_0 = 0.008, z_b = 800.0 ! N=N_0 exp(z/z_b) 10 | real*8, parameter :: U00 = 0.5, y_star=50.e3,dy_star=20e3, h_star=500, dh_star = 200 11 | real*8, allocatable :: u_ini(:,:,:),v_ini(:,:,:) 12 | end module config_module 13 | 14 | 15 | subroutine set_parameter 16 | ! ---------------------------------- 17 | ! set here main parameter 18 | ! ---------------------------------- 19 | use main_module 20 | use config_module 21 | use diagnostics_module 22 | use tke_module 23 | use idemix_module 24 | 25 | implicit none 26 | !nx = 1; nz = 200; ny = 1 27 | nx = 1; nz = 50; ny = 20 28 | dt_mom = 1800 29 | dt_tracer = dt_mom 30 | 31 | coord_degree = .false. 32 | enable_cyclic_x = .true. 33 | !enable_cyclic_y = .true. 34 | enable_hydrostatic = .true. 35 | eq_of_state_type = 1 36 | 37 | !enable_momentum_equation = .false. 38 | enable_thermodynamic_equation = .false. 39 | 40 | congr_epsilon = 1e-12 41 | congr_max_iterations = 5000 42 | !enable_streamfunction = .true. 43 | 44 | runlen = 365*86400.*10 45 | enable_diag_ts_monitor = .true.; ts_monint = dt_mom 46 | enable_diag_snapshots = .true.; snapint = dt_mom 47 | !enable_diag_energy = .true.; energint = snapint; energfreq = dt_tracer 48 | 49 | !enable_conserve_energy = .false. 50 | enable_store_cabbeling_heat = .true. 51 | enable_store_bottom_friction_tke = .true. 52 | 53 | enable_momentum_sources_with_AB = .true. 54 | 55 | enable_hor_friction = .true. 56 | A_h = 200 57 | 58 | !enable_implicit_vert_friction = .true.; 59 | !enable_tke = .true. 60 | 61 | enable_idemix = .true. 62 | enable_idemix3 = .true. 63 | tau_v = 3*86400. 64 | mu0 = 4./3. 65 | mu0_min = 0. 66 | tc_max = 1e-3 67 | Noverf_min0 = 0. 68 | !AB_eps = 0.03 69 | end subroutine set_parameter 70 | 71 | 72 | 73 | subroutine set_grid 74 | use main_module 75 | use config_module 76 | implicit none 77 | dxt = 5e3 78 | dyt = 100e3/ny 79 | dzt = 2000./nz !10.0 80 | end subroutine set_grid 81 | 82 | subroutine set_coriolis 83 | use main_module 84 | use config_module 85 | implicit none 86 | coriolis_t = 2*omega*sin(30.0 /180.*pi) 87 | end subroutine set_coriolis 88 | 89 | 90 | subroutine set_initial_conditions 91 | use main_module 92 | use tke_module 93 | use idemix_module 94 | use config_module 95 | implicit none 96 | integer :: i,j,k 97 | real*8 :: alpha,get_drhodT,N2 98 | real*8 :: aloc(nx,ny),bloc(ny,nz) 99 | real*8 :: uz(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) 100 | 101 | alpha = get_drhodT(35d0,5d0,0d0) 102 | 103 | allocate( u_ini(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); u_ini=0. 104 | allocate( v_ini(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); v_ini=0. 105 | salt = 35.0 106 | temp(:,:,nz,:)=25d0 107 | do k=nz-1,1,-1 108 | do j=js_pe-onx,je_pe+onx 109 | do i=is_pe-onx,ie_pe+onx ! b_z=N^2 , b=-rho/rho_0 g, T=rho/rho_T, T=-b rho_0/( rho_T g) 110 | N2 = ( N_0*exp(zt(k)/z_b) )**2 111 | temp(i,j,k,:) = ( temp(i,j,k+1,:) +dzw(k)*rho_0/(grav*alpha)*N2 )*maskT(i,j,k) 112 | enddo 113 | enddo 114 | enddo 115 | 116 | do j=js_pe,je_pe 117 | do k=1,nz 118 | u_ini(:,j,k) = U00*exp(-(yt(j)-y_star)**2/dy_star**2)*0.5*(1+tanh( (zt(k)+h_star)/dh_star )) 119 | !uz (:,j,k) = U00/dh_star*exp(-(yt(j)-y_star)**2/dy_star**2)*(1-tanh( (zt(k)+h_star)/dh_star )**2) 120 | enddo 121 | enddo 122 | do k=2,nz-1 123 | uz(:,:,k) = (u_ini(:,:,k+1)-u_ini(:,:,k-1))/(dzt(k+1)+dzt(k)) 124 | enddo 125 | uz(:,:,1)=uz(:,:,2) 126 | uz(:,:,nz)=uz(:,:,nz-1) 127 | 128 | 129 | u(:,:,:,tau) = u_ini; !v(:,:,:,tau) = v_ini 130 | u(:,:,:,taum1) = u_ini; !v(:,:,:,taum1) = v_ini 131 | u(:,:,:,taup1) = u_ini; !v(:,:,:,taup1) = v_ini 132 | 133 | ! rho0 fu = -p_y, p_z = -g rho, rho0 f u_z = -g rho_y, rho_y = - rho0 f u_z/g = alpha T_y 134 | aloc(1,js_pe:je_pe) = dyt(js_pe:je_pe) 135 | call pe0_recv_2D(nx,ny,aloc) 136 | bloc(1,:)=0. 137 | do j=1,ny-1 138 | bloc(j+1,:)=bloc(j,:) + aloc(1,j)*uz(1,j,:)*coriolis_t(is_pe,j)/grav/alpha*rho_0 139 | call pe0_bcast(bloc(j+1,:),nz) 140 | enddo 141 | do j=js_pe,je_pe 142 | do k=1,nz 143 | temp(:,j,k,:) = temp(:,j,k,:) + bloc(j,k) 144 | enddo 145 | enddo 146 | 147 | 148 | if (enable_idemix.and.enable_idemix3 ) then 149 | forc_iw_surface_u = 0.5e-6 150 | forc_iw_surface_v = 0.5e-6 151 | endif 152 | 153 | end subroutine set_initial_conditions 154 | 155 | 156 | subroutine set_forcing 157 | ! u_t = f v - f v* -p_x + Fu_z 158 | ! v_t = - f u + f u* -p_y + Fv_z 159 | use main_module 160 | use config_module 161 | implicit none 162 | integer :: k 163 | do k=1,nz 164 | !u_source(:,:,k) = -coriolis_t(:,:)*v_ini(:,:,k) 165 | !v_source(:,:,k) = coriolis_t(:,:)*u_ini(:,:,k) 166 | enddo 167 | end subroutine set_forcing 168 | 169 | subroutine set_topography 170 | use main_module 171 | implicit none 172 | kbot=1 173 | end subroutine set_topography 174 | 175 | 176 | subroutine set_diagnostics 177 | end subroutine set_diagnostics 178 | 179 | subroutine set_particles 180 | end subroutine set_particles 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /for_config/test_lee1.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! 1 D test case for idemix and leewaves 4 | !======================================================================= 5 | 6 | module config_module 7 | ! use this module only locally in this file 8 | implicit none 9 | real*8, parameter :: N_0 = 30e-4,z_b = 800.0 !N_0 = 0.008 10 | real*8, parameter :: zu0=200.0,zu1=750 11 | real*8, parameter :: h0=2000. 12 | real*8, allocatable :: u_target(:,:,:),v_target(:,:,:) 13 | end module config_module 14 | 15 | 16 | subroutine set_parameter 17 | ! ---------------------------------- 18 | ! set here main parameter 19 | ! ---------------------------------- 20 | use main_module 21 | use config_module 22 | use diagnostics_module 23 | use idemix_module 24 | 25 | implicit none 26 | 27 | nx = 1; nz = 200; ny = 1 28 | coord_degree = .false. 29 | enable_cyclic_x = .true. 30 | enable_cyclic_y = .true. 31 | enable_hydrostatic = .true. 32 | eq_of_state_type = 1 33 | 34 | enable_momentum_equation = .true. 35 | enable_momentum_sources = .true. 36 | enable_thermodynamic_equation = .false. 37 | 38 | runlen = 86400*120 39 | dt_mom = 360; dt_tracer = dt_mom 40 | enable_diag_ts_monitor = .true.; ts_monint = 6*3600! dt_mom 41 | enable_diag_snapshots = .true.; snapint = 6*3600! dt_mom 42 | 43 | 44 | enable_idemix = .true. 45 | enable_leewaves = .true. 46 | !enable_idemix_hor_diffusion = .true. 47 | 48 | tau_v = 3*86400. 49 | mu0 = 4./3. 50 | mu0_min = 0. 51 | tc_max = 1e-3 52 | Noverf_min0 = 0. 53 | 54 | !idemix3_leewaves_intervall = 2*dt_tracer 55 | 56 | enable_leewaves_slowflux = .false. 57 | 58 | end subroutine set_parameter 59 | 60 | 61 | 62 | subroutine set_grid 63 | use main_module 64 | use config_module 65 | implicit none 66 | dxt = 5e3 67 | dyt = 5e3 68 | dzt = h0/nz 69 | end subroutine set_grid 70 | 71 | subroutine set_coriolis 72 | use main_module 73 | use config_module 74 | implicit none 75 | coriolis_t = 1e-4 76 | end subroutine set_coriolis 77 | 78 | 79 | subroutine set_initial_conditions 80 | use main_module 81 | use tke_module 82 | use idemix_module 83 | use config_module 84 | implicit none 85 | integer :: i,j,k 86 | real*8 :: alpha,get_drhodT,N2 87 | 88 | 89 | salt = 35.0 90 | temp(:,:,nz,:)=25d0 91 | do k=nz-1,1,-1 92 | do j=js_pe-onx,je_pe+onx 93 | do i=is_pe-onx,ie_pe+onx ! b_z=N^2 , b=-rho/rho_0 g, T=rho/rho_T, T=-b rho_0/( rho_T g) 94 | alpha = get_drhodT(salt(i,j,k,1),temp(i,j,k+1,1),abs(zt(k))) 95 | N2 = ( 2e-4 + N_0*exp(zw(k)/z_b) )**2 96 | !N2 = ( N_0 )**2 97 | temp(i,j,k,:) = ( temp(i,j,k+1,:) +dzw(k)*rho_0/(grav*alpha)*N2 )*maskT(i,j,k) 98 | enddo 99 | enddo 100 | enddo 101 | 102 | 103 | allocate( u_target(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ) 104 | allocate( v_target(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ) 105 | do k=1,nz 106 | u_target(:,:,k) = 0.1 + 0.1*exp( -(zt(k)+zu1)**2/zu0**2) 107 | v_target(:,:,k) = 0.0 108 | u(:,:,k,tau) = u_target(:,:,k) 109 | u(:,:,k,taum1) = u_target(:,:,k) 110 | enddo 111 | 112 | h_rms = 10 113 | k_s = 1./10e3 114 | ph_s = 0 115 | k_n = k_s 116 | 117 | end subroutine set_initial_conditions 118 | 119 | 120 | subroutine set_forcing 121 | ! u_t = f v - f v* + Fu_z, v_t = - f u + f u* + Fv_z 122 | use main_module 123 | use config_module 124 | implicit none 125 | integer :: k 126 | do k=1,nz 127 | u_source(:,:,k) = -coriolis_t(:,:)*v_target(:,:,k) 128 | v_source(:,:,k) = coriolis_t(:,:)*u_target(:,:,k) 129 | enddo 130 | !u_source = (.02/86400.)*(u_target-u(:,:,:,tau)) 131 | end subroutine set_forcing 132 | 133 | subroutine set_topography 134 | use main_module 135 | implicit none 136 | kbot=1 137 | end subroutine set_topography 138 | 139 | 140 | subroutine set_diagnostics 141 | end subroutine set_diagnostics 142 | 143 | subroutine set_particles 144 | end subroutine set_particles 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /for_config/test_rossmix1.f90: -------------------------------------------------------------------------------- 1 | 2 | ! idealized setup to test wave propagation in Rossmix 3 | 4 | module config_module 5 | ! use this module only locally in this file 6 | implicit none 7 | real*8,parameter :: N_0 = 0.012, z_b = 800.0 ! N=N_0 exp(z/z_b) 8 | 9 | real*8, parameter :: L0 = 1000e3 10 | real*8, parameter :: H0 = 2000 11 | real*8, parameter :: f0 = 0.5e-4 12 | real*8, parameter :: BETA0 = 2e-11 13 | 14 | real*8, parameter :: DX = L0/32 15 | real*8, parameter :: DZ = H0/10 16 | real*8, parameter :: DT = 1200.0 17 | 18 | end module config_module 19 | 20 | 21 | 22 | 23 | 24 | subroutine set_parameter 25 | use main_module 26 | use diagnostics_module 27 | use rossmix_module 28 | use config_module 29 | implicit none 30 | 31 | nx=int(L0/DX); ny=int(L0/DX); nz = int(H0/DZ) 32 | dt_tracer= DT 33 | dt_mom = dt_tracer 34 | 35 | runlen=86400.*365.*1000 36 | enable_diag_ts_monitor = .true.; ts_monint = dt_tracer!*20 37 | enable_diag_snapshots = .true.; snapint = 8640 38 | 39 | enable_cyclic_x = .false. 40 | coord_degree = .false. 41 | eq_of_state_type = 1 42 | enable_momentum_equation = .false. 43 | enable_thermodynamic_equation = .false. 44 | 45 | enable_rossmix = .true. 46 | rossmix_barotropic_fac =10 47 | enable_rossmix_mean_flow_interaction = .false. 48 | enable_rossmix_bolus_form = .false. 49 | enable_rossmix_vertical_stress = .false. 50 | enable_rossmix_lateral_stress = .false. 51 | enable_rossmix_diffusion = .false. 52 | rossmix_calc_cg_int = 10*86400.0 53 | np = 40 54 | nm = 2 55 | end subroutine set_parameter 56 | 57 | 58 | subroutine set_grid 59 | use main_module 60 | use rossmix_module 61 | use config_module 62 | implicit none 63 | dxt = DX 64 | dyt = DX 65 | dzt = DZ 66 | y_origin= DX 67 | end subroutine set_grid 68 | 69 | 70 | subroutine set_coriolis 71 | use main_module 72 | use rossmix_module 73 | use config_module 74 | implicit none 75 | integer :: j 76 | do j=js_pe-onx,je_pe+onx 77 | coriolis_t(:,j) = f0 + BETA0*yt(j) 78 | enddo 79 | end subroutine set_coriolis 80 | 81 | 82 | subroutine set_topography 83 | use main_module 84 | implicit none 85 | kbot=1 86 | end subroutine set_topography 87 | 88 | 89 | subroutine set_initial_conditions 90 | use main_module 91 | use rossmix_module 92 | use config_module 93 | implicit none 94 | integer :: i,j,k 95 | real*8 :: alpha,get_drhodT,N2 96 | integer,parameter :: seed = 86456 97 | 98 | 99 | alpha = get_drhodT(35d0,5d0,0d0) 100 | salt = 35.0 101 | temp(:,:,nz,:)=25d0 102 | do k=nz-1,1,-1 103 | do j=js_pe-onx,je_pe+onx 104 | do i=is_pe-onx,ie_pe+onx ! b_z=N^2 , b=-rho/rho_0 g, T=rho/rho_T, T=-b rho_0/( rho_T g) 105 | N2 = ( N_0*exp(zt(k)/z_b) )**2 106 | temp(i,j,k,:) = ( temp(i,j,k+1,:) +dzw(k)*rho_0/(grav*alpha)*N2 )*maskT(i,j,k) 107 | enddo 108 | enddo 109 | enddo 110 | 111 | do k=2,np-1 112 | do j=js_pe,je_pe 113 | do i=is_pe,ie_pe 114 | E_s(i,j,k,:,:)= 10*exp( -( xt(i)-500e3)**2/50e3**2 - (yt(j)-500e3)**2/50e3**2 & 115 | -( phit(k)-4*pi/4.)**2/(pi/10)**2 ) *maskTp(i,j,k) 116 | enddo 117 | enddo 118 | enddo 119 | end subroutine set_initial_conditions 120 | 121 | 122 | subroutine set_forcing 123 | end subroutine set_forcing 124 | 125 | subroutine set_diagnostics 126 | end subroutine set_diagnostics 127 | 128 | subroutine set_particles 129 | end subroutine set_particles 130 | -------------------------------------------------------------------------------- /for_config/test_tke1.f90: -------------------------------------------------------------------------------- 1 | 2 | !======================================================================= 3 | ! 1 D test case for tke model 4 | !======================================================================= 5 | 6 | module config_module 7 | ! use this module only locally in this file 8 | implicit none 9 | real*8,parameter :: N_0 = 0.02 10 | end module config_module 11 | 12 | 13 | subroutine set_parameter 14 | ! ---------------------------------- 15 | ! set here main parameter 16 | ! ---------------------------------- 17 | use main_module 18 | use config_module 19 | use diagnostics_module 20 | use tke_module 21 | 22 | implicit none 23 | nx = 1; nz = 50; ny = 1 24 | dt_mom = 360 25 | dt_tracer = 360 26 | 27 | coord_degree = .false. 28 | enable_cyclic_x = .true. 29 | enable_cyclic_y = .true. 30 | enable_hydrostatic = .true. 31 | eq_of_state_type = 5 32 | 33 | congr_epsilon = 1e-12 34 | congr_max_iterations = 5000 35 | !enable_streamfunction = .true. 36 | 37 | runlen = 365*86400.*10 38 | enable_diag_ts_monitor = .true.; ts_monint = dt_tracer 39 | enable_diag_snapshots = .true.; snapint = 86400./6. 40 | !enable_diag_energy = .true.; energint = snapint; energfreq = dt_tracer 41 | 42 | enable_implicit_vert_friction = .true.; 43 | enable_tke = .true. 44 | alpha_tke = 30.0 45 | tke_mxl_choice = 2 46 | 47 | end subroutine set_parameter 48 | 49 | 50 | 51 | subroutine set_grid 52 | use main_module 53 | use config_module 54 | implicit none 55 | dxt = 5e3 56 | dyt = 5e3 57 | dzt = 1.0 58 | end subroutine set_grid 59 | 60 | subroutine set_coriolis 61 | use main_module 62 | use config_module 63 | implicit none 64 | coriolis_t = 2*omega*sin(30.0 /180.*pi) 65 | end subroutine set_coriolis 66 | 67 | 68 | subroutine set_initial_conditions 69 | use main_module 70 | use tke_module 71 | use config_module 72 | implicit none 73 | integer :: i,j,k 74 | real*8 :: alpha,get_drhodT 75 | 76 | salt = 35.0 77 | alpha = get_drhodT(35d0,0d0,0d0) 78 | do k=1,nz 79 | do j=js_pe-onx,je_pe+onx 80 | do i=is_pe-onx,ie_pe+onx 81 | temp(i,j,k,:) = ( 32+rho_0/grav/alpha*(-N_0**2*zt(k)) )*maskT(i,j,k) 82 | !u(i,j,k,:) = 0.5*tanh( (zt(k)-zt(nz/2))/zt(1)*3) 83 | enddo 84 | enddo 85 | enddo 86 | 87 | surface_taux = .1e-3*maskU(:,:,nz) 88 | surface_tauy = 0.0 89 | 90 | if (enable_tke ) then 91 | tke=1d-12 92 | do j=js_pe-onx+1,je_pe+onx 93 | do i=is_pe-onx+1,ie_pe+onx 94 | forc_tke_surface(i,j) = sqrt( (0.5*(surface_taux(i,j)+surface_taux(i-1,j)))**2 & 95 | +(0.5*(surface_tauy(i,j)+surface_tauy(i,j-1)))**2 )**(3./2.) 96 | enddo 97 | enddo 98 | endif 99 | 100 | end subroutine set_initial_conditions 101 | 102 | 103 | subroutine set_forcing 104 | end subroutine set_forcing 105 | 106 | subroutine set_topography 107 | use main_module 108 | implicit none 109 | kbot=1 110 | end subroutine set_topography 111 | 112 | 113 | subroutine set_diagnostics 114 | end subroutine set_diagnostics 115 | 116 | subroutine set_particles 117 | end subroutine set_particles 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /for_src/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../site_specific.mk_${HOSTTYPE} 3 | 4 | default: with_mpi 5 | 6 | modules: 7 | cd etc; make timing_module.o 8 | cd density; make density.o 9 | cd main; make main_module.o 10 | cd eke; make eke_module.o 11 | cd isoneutral; make isoneutral_module.o 12 | cd idemix; make idemix_module.o 13 | cd rossmix; make rossmix_module.o 14 | cd rossmix2; make rossmix2_module.o 15 | cd biha_thk; make biharmonic_thickness_module.o 16 | cd tke; make tke_module.o 17 | cd obc; make obc_module.o 18 | cd tracer; make tracer_module.o 19 | cd diagnostics; make diagnostics_module.o 20 | 21 | all: modules 22 | cd main; make 23 | cd advection; make 24 | cd tke; make 25 | cd eke; make 26 | cd idemix; make 27 | cd rossmix; make 28 | cd rossmix2; make 29 | cd biha_thk; make 30 | cd isoneutral; make 31 | cd external; make 32 | cd non_hydrostatic; make 33 | cd density; make 34 | cd obc; make 35 | cd tracer; make 36 | cd diagnostics; make 37 | 38 | config.o: all config.f90 39 | $(F90) $(F90FLAGS) $(CDFFLAGS) -Imain -Iisoneutral -Itke -Ieke \ 40 | -Iidemix -Irossmix -Irossmix2 -Ibiha_thk \ 41 | -Idiagnostics -Idensity -Iobc -Itracer -c config.f90 42 | 43 | with_mpi: all config.o 44 | cd parallel; make parallel_mpi.o 45 | $(F90) main/*.o advection/*.o tke/*.o eke/*.o idemix/*.o rossmix/*.o rossmix2/*.o isoneutral/*.o \ 46 | biha_thk/*.o external/*.o non_hydrostatic/*.o density/*.o obc/*.o diagnostics/*.o \ 47 | tracer/*.o config.o parallel/parallel_mpi.o etc/timing_module.o\ 48 | $(F90FLAGS) $(MPIFLAGS) $(CDFFLAGS)-o ../bin/model.x 49 | 50 | without_mpi: all config.o 51 | cd parallel; make parallel_none.o 52 | $(F90) main/*.o advection/*.o tke/*.o eke/*.o idemix/*.o rossmix/*.o rossmix2/*.o isoneutral/*.o \ 53 | biha_thk/*.o external/*.o non_hydrostatic/*.o density/*.o obc/*.o diagnostics/*.o \ 54 | tracer/*.o config.o parallel/parallel_none.o etc/timing_module.o\ 55 | $(F90FLAGS) $(CDFFLAGS)-o ../bin/model.x 56 | 57 | files = main/main_module.o main/numerics.o main/momentum_advection.o main/vertical_velocity.o 58 | time_step: all 59 | cd main; make time_step.o 60 | cd parallel; make parallel_mpi.o 61 | $(F90) $(F90FLAGS) $(CDFFLAGS) -Imain -c config.f90 62 | $(F90) config.o main/time_step.o parallel/parallel_mpi.o $(files) \ 63 | -Imain -Idensity -Iobc obc/*.o density/*.o advection/*.o $(F90FLAGS) $(MPIFLAGS) $(CDFFLAGS) -o ../bin/model.x 64 | cd main; rm time_step.o # this is a bit dirty but otherwise two main entry points 65 | 66 | dirs = density diagnostics eke etc external idemix rossmix rossmix2 biha_thk isoneutral main \ 67 | advection non_hydrostatic parallel tke obc tracer 68 | clean: 69 | for d in $(dirs); do cd $$d && make clean && cd ..; done 70 | rm -f *.o *.mod 71 | 72 | 73 | -------------------------------------------------------------------------------- /for_src/advection/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: adv_main.o adv_2nd.o adv_superbee.o adv_upwind.o adv_upwind3.o adv_dst3.o 5 | 6 | clean : 7 | rm -f *.o *.mod 8 | 9 | adv_main.o: adv_main.f90 ../main/main_module.o 10 | $(F90) $(F90FLAGS) -I../main -c adv_main.f90 11 | 12 | adv_2nd.o: adv_2nd.f90 ../main/main_module.o 13 | $(F90) $(F90FLAGS) -I../main -c adv_2nd.f90 14 | 15 | adv_superbee.o: adv_superbee.f90 ../main/main_module.o 16 | $(F90) $(F90FLAGS) -I../main -c adv_superbee.f90 17 | 18 | adv_upwind.o: adv_upwind.f90 ../main/main_module.o 19 | $(F90) $(F90FLAGS) -I../main -c adv_upwind.f90 20 | 21 | adv_upwind3.o: adv_upwind3.f90 ../main/main_module.o 22 | $(F90) $(F90FLAGS) -I../main -c adv_upwind3.f90 23 | 24 | adv_dst3.o: adv_dst3.f90 ../main/main_module.o 25 | $(F90) $(F90FLAGS) -I../main -c adv_dst3.f90 26 | 27 | -------------------------------------------------------------------------------- /for_src/advection/adv_2nd.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | subroutine adv_flux_2nd(is_,ie_,js_,je_,nz_,adv_fe,adv_fn,adv_ft,var) 6 | !--------------------------------------------------------------------------------- 7 | ! 2nd order advective tracer flux 8 | !--------------------------------------------------------------------------------- 9 | use main_module 10 | implicit none 11 | integer, intent(in) :: is_,ie_,js_,je_,nz_ 12 | real*8, intent(inout) :: adv_fe(is_:ie_,js_:je_,nz_), adv_fn(is_:ie_,js_:je_,nz_) 13 | real*8, intent(inout) :: adv_ft(is_:ie_,js_:je_,nz_), var(is_:ie_,js_:je_,nz_) 14 | integer :: i,j,k 15 | 16 | do k=1,nz 17 | do j=js_pe,je_pe 18 | do i=is_pe-1,ie_pe 19 | adv_fe(i,j,k)=0.5*(var(i,j,k) + var(i+1,j,k) )*u(i,j,k,tau)*maskU(i,j,k) 20 | enddo 21 | enddo 22 | enddo 23 | do k=1,nz 24 | do j=js_pe-1,je_pe 25 | do i=is_pe,ie_pe 26 | adv_fn(i,j,k)=cosu(j)*0.5*( var(i,j,k) + var(i,j+1,k) )*v(i,j,k,tau)*maskV(i,j,k) 27 | enddo 28 | enddo 29 | enddo 30 | do k=1,nz-1 31 | do j=js_pe,je_pe 32 | do i=is_pe,ie_pe 33 | adv_ft(i,j,k)=0.5*( var(i,j,k) + var(i,j,k+1) )*w(i,j,k,tau)*maskW(i,j,k) 34 | enddo 35 | enddo 36 | enddo 37 | adv_ft(:,:,nz)=0.0 38 | end subroutine adv_flux_2nd 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /for_src/advection/adv_upwind.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | subroutine adv_flux_upwind_wgrid(is_,ie_,js_,je_,nz_,adv_fe,adv_fn,adv_ft,var) 6 | !--------------------------------------------------------------------------------- 7 | ! Calculates advection of a tracer defined on Wgrid 8 | !--------------------------------------------------------------------------------- 9 | use main_module 10 | implicit none 11 | integer, intent(in) :: is_,ie_,js_,je_,nz_ 12 | real*8, intent(inout) :: adv_fe(is_:ie_,js_:je_,nz_), adv_fn(is_:ie_,js_:je_,nz_) 13 | real*8, intent(inout) :: adv_ft(is_:ie_,js_:je_,nz_), var(is_:ie_,js_:je_,nz_) 14 | integer :: i,j,k 15 | real*8 :: Rj 16 | real*8 :: maskUtr,maskVtr,maskWtr 17 | maskUtr(i,j,k) = maskW(i+1,j,k)*maskW(i,j,k) 18 | maskVtr(i,j,k) = maskW(i,j+1,k)*maskW(i,j,k) 19 | maskWtr(i,j,k) = maskW(i,j,k+1)*maskW(i,j,k) 20 | 21 | do k=1,nz 22 | do j=js_pe,je_pe 23 | do i=is_pe-1,ie_pe 24 | Rj =(var(i+1,j,k)-var(i ,j,k))*maskUtr(i ,j,k) 25 | adv_fe(i,j,k) = u_wgrid(i,j,k)*(var(i+1,j,k)+var(i,j,k))*0.5d0 -ABS(u_wgrid(i,j,k))*Rj*0.5d0 26 | enddo 27 | enddo 28 | enddo 29 | 30 | do k=1,nz 31 | do j=js_pe-1,je_pe 32 | do i=is_pe,ie_pe 33 | Rj =(var(i,j+1,k)-var(i,j ,k))*maskVtr(i,j ,k) 34 | adv_fn(i,j,k) = cosu(j)*v_wgrid(i,j,k)*(var(i,j+1,k)+var(i,j,k))*0.5d0 -ABS(cosu(j)*v_wgrid(i,j,k))*Rj*0.5d0 35 | enddo 36 | enddo 37 | enddo 38 | 39 | do k=1,nz-1 40 | do j=js_pe,je_pe 41 | do i=is_pe,ie_pe 42 | Rj =(var(i,j,k+1)-var(i,j,k ))*maskWtr(i,j,k ) 43 | adv_ft(i,j,k) = w_wgrid(i,j,k)*(var(i,j,k+1)+var(i,j,k))*0.5d0 -ABS(w_wgrid(i,j,k))*Rj*0.5d0 44 | enddo 45 | enddo 46 | enddo 47 | adv_ft(:,:,nz)=0.0 48 | end subroutine adv_flux_upwind_wgrid 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /for_src/advection/adv_upwind3.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | subroutine adv_flux_upwind3(is_,ie_,js_,je_,nz_,adv_fe,adv_fn,adv_ft,var) 8 | !--------------------------------------------------------------------------------- 9 | ! upwind third order from MITgcm 10 | ! Calculates the area integrated zonal flux due to advection of a tracer 11 | ! using upwind biased third-order interpolation (or the $\kappa=1/3$ scheme): 12 | ! \begin{equation*} 13 | ! F^x_{adv} = U \overline{ \theta - \frac{1}{6} \delta_{ii} \theta }^i 14 | ! + \frac{1}{12} |U| \delta_{iii} \theta 15 | ! \end{equation*} 16 | ! Near boundaries, mask all the gradients ==> still 3rd O. 17 | !--------------------------------------------------------------------------------- 18 | use main_module 19 | implicit none 20 | integer, intent(in) :: is_,ie_,js_,je_,nz_ 21 | real*8, intent(inout) :: adv_fe(is_:ie_,js_:je_,nz_), adv_fn(is_:ie_,js_:je_,nz_) 22 | real*8, intent(inout) :: adv_ft(is_:ie_,js_:je_,nz_), var(is_:ie_,js_:je_,nz_) 23 | integer :: i,j,k,km1,kp2 24 | real*8 :: Rjp,Rj,Rjm,Rjjp,Rjjm 25 | real*8, parameter :: oneSixth=1.D0/6.D0 26 | 27 | do k=1,nz 28 | do j=js_pe,je_pe 29 | do i=is_pe-1,ie_pe 30 | Rjp=(var(i+2,j,k)-var(i+1,j,k))*maskU(i+1,j,k) 31 | Rj =(var(i+1,j,k)-var(i ,j,k))*maskU(i ,j,k) 32 | Rjm=(var(i ,j,k)-var(i-1,j,k))*maskU(i-1,j,k) 33 | Rjjp=Rjp-Rj; Rjjm=Rj-Rjm 34 | adv_fe(i,j,k) = u(i,j,k,tau)*(var(i+1,j,k)+var(i,j,k) -oneSixth*( Rjjp+Rjjm ) )*0.5d0 & 35 | +ABS(u(i,j,k,tau))*0.5d0*oneSixth*( Rjjp-Rjjm ) 36 | enddo 37 | enddo 38 | enddo 39 | 40 | do k=1,nz 41 | do j=js_pe-1,je_pe 42 | do i=is_pe,ie_pe 43 | Rjp=(var(i,j+2,k)-var(i,j+1,k))*maskV(i,j+1,k) 44 | Rj =(var(i,j+1,k)-var(i,j ,k))*maskV(i,j ,k) 45 | Rjm=(var(i,j ,k)-var(i,j-1,k))*maskV(i,j-1,k) 46 | Rjjp=Rjp-Rj; Rjjm=Rj-Rjm 47 | adv_fn(i,j,k) = cosu(j)*v(i,j,k,tau)*(var(i,j+1,k)+var(i,j,k) -oneSixth*( Rjjp+Rjjm ) )*0.5d0 & 48 | +ABS(cosu(j)*v(i,j,k,tau))*0.5d0*oneSixth*( Rjjp-Rjjm ) 49 | enddo 50 | enddo 51 | enddo 52 | 53 | do k=1,nz-1 54 | kp2=min(nz,k+2); !if (kp2>np) kp2=3 55 | km1=max(1,k-1) !if (km1<1) km1=np-2 56 | do j=js_pe,je_pe 57 | do i=is_pe,ie_pe 58 | Rjp=(var(i,j,kp2)-var(i,j,k+1))*maskW(i,j,k+1) 59 | Rj =(var(i,j,k+1)-var(i,j,k ))*maskW(i,j,k ) 60 | Rjm=(var(i,j,k )-var(i,j,km1))*maskW(i,j,km1) 61 | Rjjp=Rjp-Rj; Rjjm=Rj-Rjm 62 | adv_ft(i,j,k) = w(i,j,k,tau)*(var(i,j,k+1)+var(i,j,k) -oneSixth*( Rjjp+Rjjm ) )*0.5d0 & 63 | +ABS(w(i,j,k,tau))*0.5d0*oneSixth*( Rjjp-Rjjm ) 64 | enddo 65 | enddo 66 | enddo 67 | adv_ft(:,:,nz)=0.0 68 | end subroutine adv_flux_upwind3 69 | 70 | -------------------------------------------------------------------------------- /for_src/biha_thk/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | include ../../site_specific.mk_${HOSTTYPE} 4 | 5 | all: biharmonic_thickness_module.o biharmonic_thickness_mixing.o \ 6 | biharmonic_thickness_friction.o biharmonic_thickness_diag_snap.o \ 7 | biharmonic_thickness_backscatter.o biharmonic_thickness_main.o 8 | 9 | clean : 10 | rm -f *.o *.mod 11 | 12 | 13 | biharmonic_thickness_module.o : biharmonic_thickness_module.f90 ../main/main_module.o 14 | $(F90) $(F90FLAGS) -I../main -c biharmonic_thickness_module.f90 15 | 16 | biharmonic_thickness_main.o: biharmonic_thickness_main.f90 ../main/main_module.o biharmonic_thickness_module.o 17 | $(F90) $(F90FLAGS) -I../main -c biharmonic_thickness_main.f90 18 | 19 | biharmonic_thickness_mixing.o: biharmonic_thickness_mixing.f90 ../main/main_module.o \ 20 | ../diagnostics/diagnostics_module.o biharmonic_thickness_module.o 21 | $(F90) $(F90FLAGS) -I../main -I../diagnostics -c biharmonic_thickness_mixing.f90 22 | 23 | biharmonic_thickness_friction.o: biharmonic_thickness_friction.f90 ../main/main_module.o biharmonic_thickness_module.o 24 | $(F90) $(F90FLAGS) -I../main -c biharmonic_thickness_friction.f90 25 | 26 | biharmonic_thickness_backscatter.o: biharmonic_thickness_backscatter.f90 \ 27 | ../diagnostics/diagnostics_module.o ../main/main_module.o biharmonic_thickness_module.o 28 | $(F90) $(F90FLAGS) -I../main -I../diagnostics -c biharmonic_thickness_backscatter.f90 29 | 30 | biharmonic_thickness_diag_snap.o: biharmonic_thickness_diag_snap.f90 ../main/main_module.o biharmonic_thickness_module.o 31 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -c biharmonic_thickness_diag_snap.f90 32 | 33 | 34 | -------------------------------------------------------------------------------- /for_src/biha_thk/biharmonic_thickness_main.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | subroutine biharmonic_thickness_friction 4 | use biharmonic_thickness_module 5 | implicit none 6 | 7 | if (enable_biharmonic_thickness_bolus_skew .or. enable_biharmonic_thickness_backscatter_skew & 8 | .or. enable_biharmonic_thickness_backscatter_harmonic) then 9 | call biha_find_ml_depth 10 | endif 11 | 12 | if (enable_biharmonic_thickness_explicit) call biharmonic_thickness_explicit 13 | if (enable_biharmonic_thickness_backscatter_harmonic) call biharmonic_thickness_backscatter_harmonic 14 | end subroutine biharmonic_thickness_friction 15 | 16 | 17 | subroutine biharmonic_thickness_mixing 18 | use main_module 19 | use biharmonic_thickness_module 20 | implicit none 21 | if (enable_biharmonic_thickness_bolus_skew ) call biharmonic_thickness_skew_tensor 22 | end subroutine biharmonic_thickness_mixing 23 | 24 | 25 | 26 | 27 | subroutine biharmonic_thickness_initialize 28 | use main_module 29 | use biharmonic_thickness_module 30 | implicit none 31 | real*8 :: fxa,dt_loc,fxb 32 | integer :: i,j,k 33 | 34 | if ( enable_biharmonic_thickness_explicit & 35 | .or. enable_biharmonic_thickness_bolus_skew & 36 | .or. enable_biharmonic_thickness_backscatter_skew & 37 | .or. enable_biharmonic_thickness_backscatter_harmonic) then 38 | biharmonic_thickness_active = .true. 39 | else 40 | biharmonic_thickness_active = .false. 41 | endif 42 | 43 | if ( .not. biharmonic_thickness_active) return 44 | 45 | if (enable_biharmonic_thickness_backscatter_skew .and. & 46 | .not. enable_biharmonic_thickness_bolus_skew) then 47 | if (my_pe==0) print*,'ERROR (1) in biharmonic_thickness_initialize, check source' 48 | call halt_stop('in biharmonic_thickness_initialize (1) ') 49 | endif 50 | 51 | if (enable_biharmonic_thickness_backscatter_integrate_energy .and. & 52 | .not. enable_conserve_energy) then 53 | if (my_pe==0) print*,'ERROR (2) in biharmonic_thickness_initialize, check source' 54 | call halt_stop('in biharmonic_thickness_initialize (2) ') 55 | endif 56 | 57 | 58 | if (my_pe==0) print'(a)',' setting up biharmonic thickness mixing' 59 | 60 | 61 | call allocate_biharmonic_thickness_module 62 | 63 | call init_snap_biharmonic_thickness 64 | 65 | if (enable_biharmonic_thickness_explicit) then 66 | fxa = 0. 67 | dt_loc = dt_mom/biharmonic_thickness_mixing_iter 68 | do k=1,nz 69 | do j=js_pe,je_pe 70 | do i=is_pe,ie_pe 71 | fxb = A_thkbi*(cost(j)**biha_friction_cosPower)**2 * (1./10.)**2 72 | fxa = max( fxa, fxb*dt_loc*2/(cost(j)*dxt(i))**2*2/dzt(k)**2 ) 73 | fxa = max( fxa, fxb*dt_loc*2/( dyt(j))**2*2/dzt(k)**2 ) 74 | enddo 75 | enddo 76 | enddo 77 | call global_max(fxa) 78 | if (my_pe==0) print*,' biharm. thickness diffusion max criterium = ',fxa 79 | if (fxa>1) then 80 | if (my_pe==0) print*,'ERROR: A_thkbi too large, criterium must be <1' 81 | !call halt_stop('in setup') 82 | endif 83 | endif 84 | 85 | 86 | end subroutine biharmonic_thickness_initialize 87 | 88 | 89 | 90 | 91 | subroutine biha_find_ml_depth!(mld,mldu,mldv) 92 | use main_module 93 | use biharmonic_thickness_module 94 | implicit none 95 | integer :: i,j,k 96 | real*8 :: N2_min,N2_int,fxa,get_rho 97 | integer :: ml_algorithm =1 98 | real*8 :: ml_Nsqr_fac = 8d0 ! for mixed layer criterion 99 | real*8 :: ml_Delta_rho = 0.02 ! for mixed layer criterion 100 | 101 | !----------------------------------------------------------------------- 102 | ! find mixed layer depth 103 | !----------------------------------------------------------------------- 104 | if (ml_algorithm == 1) then 105 | ! as given in Fox-Kemper et al. but with modification wrt isoneutral_ml 106 | mld=dzw(nz)/2. 107 | do j=js_pe-onx,je_pe+onx 108 | do i=is_pe-onx,ie_pe+onx 109 | if (kbot(i,j)>0 .and. Nsqr(i,j,nz,tau) < 1d-12) then 110 | N2_min = max(0d0,Nsqr(i,j,nz,tau)); N2_int=0d0; 111 | do k=nz-1,kbot(i,j),-1 112 | fxa = max(0d0,Nsqr(i,j,k,tau)) 113 | if ( fxa-N2_min .gt. ml_Nsqr_fac*N2_int/mld(i,j)) exit 114 | N2_min = min(fxa,N2_min) 115 | N2_int = N2_int + fxa*dzw(k) 116 | mld(i,j) = mld(i,j) + dzw(k) 117 | enddo 118 | endif 119 | enddo 120 | enddo 121 | 122 | elseif (ml_algorithm == 3) then 123 | do j=js_pe-onx,je_pe+onx 124 | do i=is_pe-onx,ie_pe+onx 125 | if (kbot(i,j)>0) then 126 | do k=nz-1,kbot(i,j),-1 127 | mld(i,j) = zw(nz)-zw(k) 128 | if ( get_rho(salt(i,j,k,tau),temp(i,j,k,tau),abs(zt(nz))) .gt. rho(i,j,nz,tau) +ml_Delta_rho ) exit 129 | enddo 130 | endif 131 | enddo 132 | enddo 133 | else 134 | call halt_stop('ERROR in biha_find_ml_depth: wrong parameter for ml_algorithm ') 135 | endif 136 | 137 | mldu=mld; mldv=mld 138 | do i=is_pe-onx,ie_pe+onx-1 139 | mldu(i,:) = 0.5*(mld(i+1,:)+mld(i,:)) 140 | enddo 141 | do j=js_pe-onx,je_pe+onx-1 142 | mldv(:,j) = 0.5*(mld(:,j+1)+mld(:,j)) 143 | enddo 144 | end subroutine biha_find_ml_depth 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /for_src/biha_thk/biharmonic_thickness_module.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | module biharmonic_thickness_module 4 | !======================================================================= 5 | !======================================================================= 6 | implicit none 7 | logical :: biharmonic_thickness_active = .false. 8 | logical :: enable_biharmonic_thickness_explicit = .false. ! enable biharmonic thickness mixing (in res. mom. formulation) 9 | logical :: enable_biharmonic_thickness_bolus_skew = .false. ! enable biharmonic thickness mixing, bolus formulation skew 10 | logical :: enable_biharmonic_thickness_backscatter_harmonic = .false. 11 | logical :: enable_biharmonic_thickness_backscatter_skew = .false. 12 | logical :: enable_biharmonic_thickness_backscatter_integrate_energy = .false. 13 | logical :: enable_biharmonic_thickness_backscatter_taper_mld = .false. 14 | integer :: biharmonic_thickness_backscatter_smooth = 1 15 | 16 | real*8 :: biha_dslope=1d-9 17 | real*8 :: biha_slopec=2d-9 18 | real*8 :: A_thk_0 = 0. 19 | real*8 :: mld0_thk = 75.0 20 | real*8 :: e_back_diff = 1000.0 21 | real*8 :: A_thk_max = 500. 22 | real*8 :: L_back = 40. 23 | real*8 :: e_back_damp = 0.0 24 | 25 | logical :: enable_biharmonic_thickness_cut_upper = .false. ! cut upper XX meter for explicit formulation 26 | logical :: enable_biharmonic_thickness_scale_A_thkbi_cut = .false. ! scale that parameter with cos(lat)**2 for explicit 27 | 28 | real*8 :: A_thkbi = 0.0 ! biharmonic thickness diffusivity in m^4/s 29 | real*8 :: thkbi_f_min = 1e-6 ! threshold for Coriolis parameter in expl. bihar. thickness formulation in 1/s 30 | real*8 :: K_thkbi_clip = 5. ! clipping for visc. in multiples of f, only biharmonic_thickness_mixing_explicit 31 | 32 | integer:: biharmonic_thickness_mixing_iter = 1 ! iterations in sub loop for the explicit formulation 33 | real*8 :: A_thkbi_cut = 0.5 34 | real*8 :: A_thkbi_cut_upper_len = 35. 35 | 36 | real*8,allocatable :: K_thkbi(:,:,:) ! actual A_thkbi after clipping 37 | real*8,allocatable :: A_thk(:,:,:) ! 38 | real*8,allocatable :: diss_biha_skew(:,:,:) 39 | real*8,allocatable :: diss_back(:,:,:) 40 | 41 | real*8,allocatable :: mld(:,:),mldu(:,:),mldv(:,:) 42 | real*8,allocatable :: e_back(:,:,:) 43 | 44 | real*8,allocatable :: diag_Bx(:,:,:),diag_By(:,:,:) 45 | real*8,allocatable :: diag_Bx_back(:,:,:),diag_By_back(:,:,:) 46 | end module biharmonic_thickness_module 47 | 48 | 49 | 50 | 51 | 52 | subroutine allocate_biharmonic_thickness_module 53 | use main_module 54 | use biharmonic_thickness_module 55 | implicit none 56 | 57 | if ( .not. biharmonic_thickness_active) return 58 | 59 | allocate( K_thkbi(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); K_thkbi = 0.0 60 | allocate( mld(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ) ; mld=0d0 61 | allocate( mldu(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); mldu=0d0 62 | allocate( mldv(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); mldv=0d0 63 | 64 | allocate( diag_Bx(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); diag_Bx=0d0 65 | allocate( diag_By(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); diag_By=0d0 66 | 67 | if ( enable_biharmonic_thickness_backscatter_skew & 68 | .or. enable_biharmonic_thickness_backscatter_harmonic ) then 69 | allocate( A_thk(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); A_thk = 0.0 70 | allocate( diag_Bx_back(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); diag_Bx_back = 0.0 71 | allocate( diag_By_back(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); diag_By_back = 0.0 72 | if (enable_conserve_energy) then 73 | allocate( diss_back(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); diss_back = 0 74 | endif 75 | if (enable_biharmonic_thickness_backscatter_integrate_energy) then 76 | allocate( e_back(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,3) ); e_back=0d0 77 | endif 78 | endif 79 | 80 | if ( enable_biharmonic_thickness_bolus_skew .and. enable_conserve_energy) then 81 | allocate( diss_biha_skew(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); diss_biha_skew = 0 82 | endif 83 | 84 | 85 | end subroutine allocate_biharmonic_thickness_module 86 | 87 | -------------------------------------------------------------------------------- /for_src/density/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: density.o get_rho.o 5 | 6 | check_density : check_density.f90 density.o 7 | $(F90) check_density.f90 density.o $(F90FLAGS) $(CDFFLAGS) \ 8 | -o ../../bin/check_density.x 9 | clean : 10 | rm -f *.o *.mod 11 | 12 | density.o: density.f90 13 | $(F90) $(F90FLAGS) -c density.f90 14 | get_rho.o: get_rho.f90 ../main/main_module.o density.o 15 | $(F90) $(F90FLAGS) -I../main -c get_rho.f90 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /for_src/density/check_density.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | ! 4 | ! test modules in density.f90 and write TSP diagrams in cdf file 5 | ! 6 | 7 | program check_density 8 | use nonlin1_eq_of_state 9 | use nonlin2_eq_of_state 10 | use gsw_eq_of_state 11 | implicit none 12 | integer, parameter :: nx=40,ny=40,nz=40 13 | real*8 :: T(nx),S(ny),P(nz),rho1(nx,ny,nz),rho2(nx,ny,nz),rho3(nx,ny,nz) 14 | real*8 :: drho1dT(nx,ny,nz),drho2dT(nx,ny,nz),drho3dT(nx,ny,nz) 15 | real*8 :: drho1dS(nx,ny,nz),drho2dS(nx,ny,nz),drho3dS(nx,ny,nz) 16 | real*8 :: drho1dP(nx,ny,nz),drho2dP(nx,ny,nz),drho3dP(nx,ny,nz) 17 | real*8 :: Hd1(nx,ny,nz),Hd2(nx,ny,nz),Hd3(nx,ny,nz) 18 | real*8 :: dHd3dT(nx,ny,nz),dHd2dT(nx,ny,nz) 19 | real*8 :: dHd3dS(nx,ny,nz),dHd2dS(nx,ny,nz) 20 | integer :: i,j,k 21 | include "netcdf.inc" 22 | integer :: iret,ncid,tdim,sdim,pdim,tid,sid,pid,rho1id,rho2id,rho3id 23 | integer :: drho1dTid,drho2dTid,drho3dTid 24 | integer :: drho1dSid,drho2dSid,drho3dSid 25 | integer :: drho1dPid,drho2dPid,drho3dPid 26 | integer :: Hd1id,Hd2id,Hd3id 27 | integer :: dHd3dTid 28 | integer :: dHd2dTid 29 | integer :: dHd3dSid 30 | integer :: dHd2dSid 31 | 32 | 33 | do i=1,nx 34 | do j=1,ny 35 | do k=1,nz 36 | T(i) = -2.+27.*(i-1.0)/nx 37 | S(j) = 33+4*(j-1.0)/ny 38 | !S(j) = 35*(j-1.0)/ny 39 | P(k) = 5000*(k-1.)/nz 40 | rho3(i,j,k) = gsw_rho(S(j),T(i),P(k)) 41 | rho2(i,j,k) = nonlin2_eq_of_state_rho(S(j),T(i),P(k)) 42 | drho3dT(i,j,k) = gsw_drhodT(S(j),T(i),P(k)) 43 | drho2dT(i,j,k) = nonlin2_eq_of_state_drhodT(T(i),P(k)) 44 | drho3dS(i,j,k) = gsw_drhodS(S(j),T(i),P(k)) 45 | drho2dS(i,j,k) = nonlin2_eq_of_state_drhodS() 46 | drho3dP(i,j,k) = gsw_drhodP(S(j),T(i),P(k)) 47 | drho2dP(i,j,k) = nonlin2_eq_of_state_drhodP(T(i)) 48 | Hd3(i,j,k) = gsw_dyn_enthalpy(S(j),T(i),P(k)) 49 | Hd2(i,j,k) = nonlin2_eq_of_state_dyn_enthalpy(S(j),T(i),P(k)) 50 | dHd3dT(i,j,k) = gsw_dHdT(S(j),T(i),P(k)) 51 | dHd3dS(i,j,k) = gsw_dHdS(S(j),T(i),P(k)) 52 | dHd2dT(i,j,k) = nonlin2_eq_of_state_int_drhodT(T(i),P(k))*(-9.81/1024.) 53 | dHd2dS(i,j,k) = nonlin2_eq_of_state_int_drhodS(P(k))*(-9.81/1024.) 54 | enddo 55 | enddo 56 | enddo 57 | 58 | 59 | iret = nf_create ('check_density.cdf', nf_clobber, ncid) 60 | tdim = ncddef(ncid, 'T', nx , iret) 61 | sdim = ncddef(ncid, 'S', ny , iret) 62 | pdim = ncddef(ncid, 'P', nz , iret) 63 | tid = ncvdef (ncid,'T',NCFLOAT,1,tdim,iret) 64 | sid = ncvdef (ncid,'S',NCFLOAT,1,sdim,iret) 65 | pid = ncvdef (ncid,'P',NCFLOAT,1,pdim,iret) 66 | rho1id = ncvdef (ncid,'rho1',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 67 | rho2id = ncvdef (ncid,'rho2',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 68 | rho3id = ncvdef (ncid,'rho3',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 69 | Hd1id = ncvdef (ncid,'Hd1',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 70 | Hd2id = ncvdef (ncid,'Hd2',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 71 | Hd3id = ncvdef (ncid,'Hd3',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 72 | drho1dTid = ncvdef (ncid,'drho1dT',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 73 | drho2dTid = ncvdef (ncid,'drho2dT',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 74 | drho3dTid = ncvdef (ncid,'drho3dT',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 75 | drho1dSid = ncvdef (ncid,'drho1dS',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 76 | drho2dSid = ncvdef (ncid,'drho2dS',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 77 | drho3dSid = ncvdef (ncid,'drho3dS',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 78 | drho1dPid = ncvdef (ncid,'drho1dP',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 79 | drho2dPid = ncvdef (ncid,'drho2dP',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 80 | drho3dPid = ncvdef (ncid,'drho3dP',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 81 | dHd3dTid = ncvdef (ncid,'dHd3dT',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 82 | dHd3dSid = ncvdef (ncid,'dHd3dS',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 83 | dHd2dTid = ncvdef (ncid,'dHd2dT',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 84 | dHd2dSid = ncvdef (ncid,'dHd2dS',NCFLOAT,3,(/tdim,sdim,pdim/),iret) 85 | iret = NF_PUT_ATT_TEXT (ncid, tid,'name',len('temperature'),'temperature') 86 | iret = NF_PUT_ATT_TEXT (ncid, tid,'unit',len('deg C'),'deg C') 87 | iret = NF_PUT_ATT_TEXT (ncid, sid,'name',len('salinity'),'salinity') 88 | iret = NF_PUT_ATT_TEXT (ncid, sid,'unit',len('g/kg'),'g/kg') 89 | iret = NF_PUT_ATT_TEXT (ncid, pid,'name',len('pressure'),'pressure') 90 | iret = NF_PUT_ATT_TEXT (ncid, pid,'unit',len('dbar'),'dbar') 91 | iret = NF_PUT_ATT_TEXT (ncid, rho1id,'name',len('density'),'density') 92 | iret = NF_PUT_ATT_TEXT (ncid, rho1id,'unit',len('kg/m^3'),'kg/m^3') 93 | iret = NF_PUT_ATT_TEXT (ncid, rho2id,'name',len('density'),'density') 94 | iret = NF_PUT_ATT_TEXT (ncid, rho2id,'unit',len('kg/m^3'),'kg/m^3') 95 | iret = NF_PUT_ATT_TEXT (ncid, rho3id,'name',len('density'),'density') 96 | iret = NF_PUT_ATT_TEXT (ncid, rho3id,'unit',len('kg/m^3'),'kg/m^3') 97 | iret = nf_enddef(ncid) 98 | iret = nf_put_vara_double(ncid,tid,1,nx ,T) 99 | iret = nf_put_vara_double(ncid,sid,1,ny ,S) 100 | iret = nf_put_vara_double(ncid,pid,1,nz ,P) 101 | iret = nf_put_vara_double(ncid,rho1id,(/1,1,1/),(/nx,ny,nz/) ,rho1) 102 | iret = nf_put_vara_double(ncid,rho2id,(/1,1,1/),(/nx,ny,nz/) ,rho2) 103 | iret = nf_put_vara_double(ncid,rho3id,(/1,1,1/),(/nx,ny,nz/) ,rho3) 104 | iret = nf_put_vara_double(ncid,Hd1id,(/1,1,1/),(/nx,ny,nz/) ,Hd1) 105 | iret = nf_put_vara_double(ncid,Hd2id,(/1,1,1/),(/nx,ny,nz/) ,Hd2) 106 | iret = nf_put_vara_double(ncid,Hd3id,(/1,1,1/),(/nx,ny,nz/) ,Hd3) 107 | iret = nf_put_vara_double(ncid,drho1dTid,(/1,1,1/),(/nx,ny,nz/) ,drho1dT) 108 | iret = nf_put_vara_double(ncid,drho2dTid,(/1,1,1/),(/nx,ny,nz/) ,drho2dT) 109 | iret = nf_put_vara_double(ncid,drho3dTid,(/1,1,1/),(/nx,ny,nz/) ,drho3dT) 110 | iret = nf_put_vara_double(ncid,drho1dSid,(/1,1,1/),(/nx,ny,nz/) ,drho1dS) 111 | iret = nf_put_vara_double(ncid,drho2dSid,(/1,1,1/),(/nx,ny,nz/) ,drho2dS) 112 | iret = nf_put_vara_double(ncid,drho3dSid,(/1,1,1/),(/nx,ny,nz/) ,drho3dS) 113 | iret = nf_put_vara_double(ncid,drho1dPid,(/1,1,1/),(/nx,ny,nz/) ,drho1dP) 114 | iret = nf_put_vara_double(ncid,drho2dPid,(/1,1,1/),(/nx,ny,nz/) ,drho2dP) 115 | iret = nf_put_vara_double(ncid,drho3dPid,(/1,1,1/),(/nx,ny,nz/) ,drho3dP) 116 | iret = nf_put_vara_double(ncid,dHd3dTid,(/1,1,1/),(/nx,ny,nz/) ,dHd3dT) 117 | iret = nf_put_vara_double(ncid,dHd3dSid,(/1,1,1/),(/nx,ny,nz/) ,dHd3dS) 118 | iret = nf_put_vara_double(ncid,dHd2dTid,(/1,1,1/),(/nx,ny,nz/) ,dHd2dT) 119 | iret = nf_put_vara_double(ncid,dHd2dSid,(/1,1,1/),(/nx,ny,nz/) ,dHd2dS) 120 | iret = nf_close (ncid) 121 | end program check_density 122 | -------------------------------------------------------------------------------- /for_src/diagnostics/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: diagnostics_module.o diag_main.o diag_averages.o diag_over.o diag_snap.o \ 5 | diag_energy.o diag_particles.o diag_particles_netcdf.o diag_variance.o \ 6 | diag_snap_tke.o diag_snap_eke.o diag_snap_isoneutral.o diag_snap_energy.o \ 7 | diag_snap_idemix.o diag_snap_tracer.o diag_snap_rossmix.o diag_snap_fluxes.o \ 8 | diag_snap_tendency.o diag_snap_parallel.o diag_snap_chunks.o diag_opt_balance.o 9 | 10 | clean : 11 | rm -f *.o *.mod 12 | 13 | diagnostics_module.o: diagnostics_module.f90 14 | $(F90) $(F90FLAGS) -c diagnostics_module.f90 15 | 16 | diag_main.o: diag_main.f90 ../main/main_module.o ../tke/tke_module.o \ 17 | ../isoneutral/isoneutral_module.o ../eke/eke_module.o ../rossmix/rossmix_module.o ../rossmix2/rossmix2_module.o\ 18 | ../idemix/idemix_module.o ../tracer/tracer_module.o diagnostics_module.o 19 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../tke -I../isoneutral -I../eke -I../idemix -I../rossmix -I../rossmix2 -I../tracer -c diag_main.f90 20 | 21 | diag_averages.o: diag_averages.f90 ../main/main_module.o diagnostics_module.o 22 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -c diag_averages.f90 23 | 24 | diag_variance.o: diag_variance.f90 ../main/main_module.o diagnostics_module.o 25 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -c diag_variance.f90 26 | 27 | diag_energy.o: diag_energy.f90 ../main/main_module.o ../tke/tke_module.o ../isoneutral/isoneutral_module.o \ 28 | ../eke/eke_module.o ../idemix/idemix_module.o diagnostics_module.o 29 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../tke -I../eke -I../idemix -I../isoneutral -c diag_energy.f90 30 | 31 | diag_snap.o: diag_snap.f90 ../main/main_module.o diagnostics_module.o 32 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -c diag_snap.f90 33 | 34 | diag_snap_idemix.o: diag_snap_idemix.f90 ../main/main_module.o ../idemix/idemix_module.o diagnostics_module.o 35 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../idemix -c diag_snap_idemix.f90 36 | 37 | diag_snap_rossmix.o: diag_snap_rossmix.f90 ../main/main_module.o ../rossmix/rossmix_module.o diagnostics_module.o 38 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../rossmix -c diag_snap_rossmix.f90 39 | 40 | diag_snap_energy.o: diag_snap_energy.f90 ../main/main_module.o ../isoneutral/isoneutral_module.o ../idemix/idemix_module.o diagnostics_module.o 41 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../isoneutral -I../idemix -c diag_snap_energy.f90 42 | 43 | diag_snap_isoneutral.o: diag_snap_isoneutral.f90 ../main/main_module.o ../isoneutral/isoneutral_module.o diagnostics_module.o 44 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../isoneutral -c diag_snap_isoneutral.f90 45 | 46 | diag_snap_eke.o: diag_snap_eke.f90 ../main/main_module.o ../eke/eke_module.o diagnostics_module.o 47 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../eke -c diag_snap_eke.f90 48 | 49 | diag_snap_tracer.o: diag_snap_tracer.f90 ../main/main_module.o ../tracer/tracer_module.o diagnostics_module.o 50 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../tracer -c diag_snap_tracer.f90 51 | 52 | diag_snap_tke.o: diag_snap_tke.f90 ../main/main_module.o ../tke/tke_module.o diagnostics_module.o 53 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../tke -c diag_snap_tke.f90 54 | 55 | diag_over.o: diag_over.f90 ../main/main_module.o ../isoneutral/isoneutral_module.o ../rossmix2/rossmix2_module.o 56 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../isoneutral -I../rossmix2 -c diag_over.f90 57 | 58 | diag_particles.o: diag_particles.f90 ../main/main_module.o 59 | $(F90) $(F90FLAGS) -I../main -c diag_particles.f90 60 | diag_particles_netcdf.o: diag_particles_netcdf.f90 ../main/main_module.o diag_particles.o 61 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -c diag_particles_netcdf.f90 62 | 63 | diag_snap_fluxes.o: diag_snap_fluxes.f90 ../main/main_module.o ../isoneutral/isoneutral_module.o 64 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../isoneutral -c diag_snap_fluxes.f90 65 | 66 | diag_snap_tendency.o: diag_snap_tendency.f90 ../main/main_module.o ../isoneutral/isoneutral_module.o 67 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../isoneutral -c diag_snap_tendency.f90 68 | 69 | diag_snap_parallel.o: diag_snap_parallel.F90 ../main/main_module.o 70 | $(F90) $(F90FLAGS) $(CDFFLAGS) $(MPIFLAGS) -I../main -c diag_snap_parallel.F90 71 | 72 | diag_snap_chunks.o: diag_snap_chunks.f90 ../main/main_module.o 73 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -c diag_snap_chunks.f90 74 | 75 | diag_opt_balance.o: diag_opt_balance.f90 ../main/main_module.o 76 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -c diag_opt_balance.f90 77 | 78 | -------------------------------------------------------------------------------- /for_src/diagnostics/diag_particles_netcdf.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | subroutine init_write_particles 9 | !======================================================================= 10 | ! initialize netcdf output 11 | !======================================================================= 12 | use main_module 13 | use particles_module 14 | implicit none 15 | include "netcdf.inc" 16 | integer :: ncid,tdim,pdim,tid,xid,yid,zid,iret,vid 17 | character :: name*24, unit*16 18 | 19 | if (my_pe==0) then 20 | ncid = nccre ('float.cdf', NCCLOB, iret) 21 | iret=nf_set_fill(ncid, NF_NOFILL, iret) 22 | tdim = ncddef(ncid, 'Time', nf_unlimited, iret) 23 | pdim = ncddef(ncid, 'Number', max(1,nptraj) , iret) 24 | tid = ncvdef (ncid,'Time', NCFLOAT,1,(/tdim/),iret) 25 | xid = ncvdef (ncid,'x_pos', NCFLOAT,2,(/pdim,tdim/),iret) 26 | yid = ncvdef (ncid,'y_pos', NCFLOAT,2,(/pdim,tdim/),iret) 27 | zid = ncvdef (ncid,'z_pos', NCFLOAT,2,(/pdim,tdim/),iret) 28 | call ncaptc(ncid, tid, 'long_name', NCCHAR, 4, 'Time', iret) 29 | call ncaptc(ncid, tid, 'units', NCCHAR, 4, 'days', iret) 30 | call ncaptc(ncid, Tid,'time_origin',NCCHAR, 20,'01-JAN-1900 00:00:00', iret) 31 | 32 | if (coord_degree) then 33 | name = 'Longitude'; unit = 'degrees E' 34 | else 35 | name = 'zonal position'; unit = 'km' 36 | endif 37 | call ncaptc(ncid, xid, 'long_name', NCCHAR, 24, name, iret) 38 | call ncaptc(ncid, xid, 'units', NCCHAR, 16, unit, iret) 39 | 40 | if (coord_degree) then 41 | name = 'Latitude'; unit = 'degrees N' 42 | else 43 | name = 'meridional position'; unit = 'km' 44 | endif 45 | call ncaptc(ncid, yid, 'long_name', NCCHAR, 24, name, iret) 46 | call ncaptc(ncid, yid, 'units', NCCHAR, 16, unit, iret) 47 | 48 | name = 'Height'; unit = 'm' 49 | call ncaptc(ncid, zid, 'long_name', NCCHAR, 24, name, iret) 50 | call ncaptc(ncid, zid, 'units', NCCHAR, 16, unit, iret) 51 | 52 | vid = ncvdef (ncid,'u', NCFLOAT,2,(/pdim,tdim/),iret) 53 | name = 'Zonal velocity'; unit = 'm/s' 54 | call ncaptc(ncid, vid, 'long_name', NCCHAR, 24, name, iret) 55 | call ncaptc(ncid, vid, 'units', NCCHAR, 16, unit, iret) 56 | 57 | vid = ncvdef (ncid,'v', NCFLOAT,2,(/pdim,tdim/),iret) 58 | name = 'Meridional velocity'; unit = 'm/s' 59 | call ncaptc(ncid, vid, 'long_name', NCCHAR, 24, name, iret) 60 | call ncaptc(ncid, vid, 'units', NCCHAR, 16, unit, iret) 61 | 62 | vid = ncvdef (ncid,'w', NCFLOAT,2,(/pdim,tdim/),iret) 63 | name = 'Vertical velocity'; unit = 'm/s' 64 | call ncaptc(ncid, vid, 'long_name', NCCHAR, 24, name, iret) 65 | call ncaptc(ncid, vid, 'units', NCCHAR, 16, unit, iret) 66 | 67 | vid = ncvdef (ncid,'temp', NCFLOAT,2,(/pdim,tdim/),iret) 68 | name = 'Temperature'; unit = 'deg C' 69 | call ncaptc(ncid, vid, 'long_name', NCCHAR, 24, name, iret) 70 | call ncaptc(ncid, vid, 'units', NCCHAR, 16, unit, iret) 71 | 72 | vid = ncvdef (ncid,'salt', NCFLOAT,2,(/pdim,tdim/),iret) 73 | name = 'Salinity'; unit = 'g/kg' 74 | call ncaptc(ncid, vid, 'long_name', NCCHAR, 24, name, iret) 75 | call ncaptc(ncid, vid, 'units', NCCHAR, 16, unit, iret) 76 | 77 | iret = nf_close (ncid) 78 | endif 79 | end subroutine init_write_particles 80 | 81 | 82 | 83 | subroutine write_particles 84 | !======================================================================= 85 | ! write to netcdf file 86 | !======================================================================= 87 | use main_module 88 | use particles_module 89 | implicit none 90 | include "netcdf.inc" 91 | integer :: ncid,tdim,tid,xid,yid,zid,iret,ilen,n,uid,vid,wid,teid,sid 92 | real*8 :: fxa 93 | 94 | if (my_pe==0) then 95 | print*,'writing particles to file float.cdf' 96 | iret=nf_open('float.cdf',NF_WRITE,ncid) 97 | iret=nf_set_fill(ncid, NF_NOFILL, iret) 98 | iret=nf_inq_varid(ncid,'x_pos',xid) 99 | iret=nf_inq_varid(ncid,'y_pos',yid) 100 | iret=nf_inq_varid(ncid,'z_pos',zid) 101 | iret=nf_inq_varid(ncid,'u',uid) 102 | iret=nf_inq_varid(ncid,'v',vid) 103 | iret=nf_inq_varid(ncid,'w',wid) 104 | iret=nf_inq_varid(ncid,'temp',teid) 105 | iret=nf_inq_varid(ncid,'salt',sid) 106 | iret=nf_inq_dimid(ncid,'Time',tdim) 107 | iret=nf_inq_dimlen(ncid, tdim,ilen) 108 | iret=nf_inq_varid(ncid,'Time',tid) 109 | ilen=ilen+1 110 | fxa = itt*dt_tracer/86400.0 111 | iret= nf_put_vara_double(ncid,tid,(/ilen/),(/1/),(/fxa/)) 112 | do n=1,nptraj 113 | if (coord_degree) then 114 | iret= nf_put_vara_double(ncid,xid,(/n,ilen/),(/1,1/),(/pxyz(1,n)/)) 115 | iret= nf_put_vara_double(ncid,yid,(/n,ilen/),(/1,1/),(/pxyz(2,n)/)) 116 | else 117 | iret= nf_put_vara_double(ncid,xid,(/n,ilen/),(/1,1/),(/pxyz(1,n)/1e3/)) 118 | iret= nf_put_vara_double(ncid,yid,(/n,ilen/),(/1,1/),(/pxyz(2,n)/1e3/)) 119 | endif 120 | iret= nf_put_vara_double(ncid,zid,(/n,ilen/),(/1,1/),(/pxyz(3,n)/)) 121 | iret= nf_put_vara_double(ncid,uid,(/n,ilen/),(/1,1/),(/puvw(1,n)/)) 122 | iret= nf_put_vara_double(ncid,vid,(/n,ilen/),(/1,1/),(/puvw(2,n)/)) 123 | iret= nf_put_vara_double(ncid,wid,(/n,ilen/),(/1,1/),(/puvw(3,n)/)) 124 | iret= nf_put_vara_double(ncid,teid,(/n,ilen/),(/1,1/),(/pts(1,n)/)) 125 | iret= nf_put_vara_double(ncid,sid,(/n,ilen/),(/1,1/),(/pts(2,n)/)) 126 | enddo 127 | call ncclos (ncid, iret) 128 | endif 129 | end subroutine write_particles 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /for_src/diagnostics/diag_snap_tendency.f90: -------------------------------------------------------------------------------- 1 | 2 | subroutine diag_snap_tendency 3 | use main_module 4 | implicit none 5 | include "netcdf.inc" 6 | integer :: ncid,iret,itdimid,ilen,itimeid,id,k 7 | real*8 :: cloc(nx,ny),fxa 8 | real*8, parameter :: spval = -1.0d33 9 | 10 | if (my_pe == 0 ) then 11 | iret=nf_open('pyOM_tendency.cdf',NF_WRITE,ncid) 12 | print'(a)',' writing to file pyOM_tendency.cdf' 13 | iret=nf_set_fill(ncid, NF_NOFILL, iret) 14 | iret=nf_inq_dimid(ncid,'Time',itdimid) 15 | iret=nf_inq_dimlen(ncid, itdimid,ilen) 16 | ilen=ilen+1 17 | fxa = itt*dt_tracer/86400.0 18 | iret=nf_inq_varid(ncid,'Time',itimeid) 19 | iret= nf_put_vara_double(ncid,itimeid,(/ilen/),(/1/),(/fxa/)) 20 | call ncclos (ncid, iret) 21 | endif 22 | call fortran_barrier 23 | 24 | if (my_pe == 0 ) then 25 | iret=nf_open('pyOM_tendency.cdf',NF_WRITE,ncid) 26 | iret=nf_inq_dimid(ncid,'Time',itdimid) 27 | iret=nf_inq_dimlen(ncid, itdimid,ilen) 28 | endif 29 | 30 | do k=1,nz 31 | cloc(is_pe:ie_pe,js_pe:je_pe) = dtemp(is_pe:ie_pe,js_pe:je_pe,k,tau) 32 | where( maskT(is_pe:ie_pe,js_pe:je_pe,k) == 0.) cloc(is_pe:ie_pe,js_pe:je_pe) = spval 33 | call pe0_recv_2D(nx,ny,cloc) 34 | if (my_pe == 0 ) then 35 | iret=nf_inq_varid(ncid,'dtemp_adv',id) 36 | iret= nf_put_vara_double(ncid,id,(/1,1,k,ilen/), (/nx,ny,1,1/),cloc) 37 | endif 38 | 39 | cloc(is_pe:ie_pe,js_pe:je_pe) = dsalt(is_pe:ie_pe,js_pe:je_pe,k,tau) 40 | where( maskT(is_pe:ie_pe,js_pe:je_pe,k) == 0.) cloc(is_pe:ie_pe,js_pe:je_pe) = spval 41 | call pe0_recv_2D(nx,ny,cloc) 42 | if (my_pe == 0 ) then 43 | iret=nf_inq_varid(ncid,'dsalt_adv',id) 44 | iret= nf_put_vara_double(ncid,id,(/1,1,k,ilen/), (/nx,ny,1,1/),cloc) 45 | endif 46 | 47 | cloc(is_pe:ie_pe,js_pe:je_pe) = dtemp_vmix(is_pe:ie_pe,js_pe:je_pe,k) 48 | where( maskT(is_pe:ie_pe,js_pe:je_pe,k) == 0.) cloc(is_pe:ie_pe,js_pe:je_pe) = spval 49 | call pe0_recv_2D(nx,ny,cloc) 50 | if (my_pe == 0 ) then 51 | iret=nf_inq_varid(ncid,'dtemp_vmix',id) 52 | iret= nf_put_vara_double(ncid,id,(/1,1,k,ilen/), (/nx,ny,1,1/),cloc) 53 | endif 54 | 55 | cloc(is_pe:ie_pe,js_pe:je_pe) = dsalt_vmix(is_pe:ie_pe,js_pe:je_pe,k) 56 | where( maskT(is_pe:ie_pe,js_pe:je_pe,k) == 0.) cloc(is_pe:ie_pe,js_pe:je_pe) = spval 57 | call pe0_recv_2D(nx,ny,cloc) 58 | if (my_pe == 0 ) then 59 | iret=nf_inq_varid(ncid,'dsalt_vmix',id) 60 | iret= nf_put_vara_double(ncid,id,(/1,1,k,ilen/), (/nx,ny,1,1/),cloc) 61 | endif 62 | 63 | cloc(is_pe:ie_pe,js_pe:je_pe) = dtemp_iso(is_pe:ie_pe,js_pe:je_pe,k) 64 | where( maskT(is_pe:ie_pe,js_pe:je_pe,k) == 0.) cloc(is_pe:ie_pe,js_pe:je_pe) = spval 65 | call pe0_recv_2D(nx,ny,cloc) 66 | if (my_pe == 0 ) then 67 | iret=nf_inq_varid(ncid,'dtemp_iso',id) 68 | iret= nf_put_vara_double(ncid,id,(/1,1,k,ilen/), (/nx,ny,1,1/),cloc) 69 | endif 70 | 71 | cloc(is_pe:ie_pe,js_pe:je_pe) = dsalt_iso(is_pe:ie_pe,js_pe:je_pe,k) 72 | where( maskT(is_pe:ie_pe,js_pe:je_pe,k) == 0.) cloc(is_pe:ie_pe,js_pe:je_pe) = spval 73 | call pe0_recv_2D(nx,ny,cloc) 74 | if (my_pe == 0 ) then 75 | iret=nf_inq_varid(ncid,'dsalt_iso',id) 76 | iret= nf_put_vara_double(ncid,id,(/1,1,k,ilen/), (/nx,ny,1,1/),cloc) 77 | endif 78 | 79 | enddo 80 | 81 | if (my_pe==0) iret = nf_close (ncid) 82 | 83 | end subroutine diag_snap_tendency 84 | 85 | 86 | subroutine init_diag_snap_tendency 87 | use main_module 88 | include "netcdf.inc" 89 | integer :: ncid,iret,lon_tdim,lon_udim,itimedim 90 | integer :: lat_tdim,lat_udim,id,z_tdim,z_udim, dims(4) 91 | character :: name*60, unit*16 92 | real*8, parameter :: spval = -1.0d33 93 | 94 | if (my_pe==0) print'(a)',' preparing file pyOM_tendency.cdf' 95 | 96 | call def_grid_cdf('pyOM_tendency.cdf') 97 | 98 | if (my_pe==0) then 99 | iret=nf_open('pyOM_tendency.cdf',NF_WRITE, ncid) 100 | iret=nf_set_fill(ncid, NF_NOFILL, iret) 101 | call ncredf(ncid, iret) 102 | iret=nf_inq_dimid(ncid,'xt',lon_tdim) 103 | iret=nf_inq_dimid(ncid,'xu',lon_udim) 104 | iret=nf_inq_dimid(ncid,'yt',lat_tdim) 105 | iret=nf_inq_dimid(ncid,'yu',lat_udim) 106 | iret=nf_inq_dimid(ncid,'zt',z_tdim) 107 | iret=nf_inq_dimid(ncid,'zu',z_udim) 108 | iret=nf_inq_dimid(ncid,'Time',itimedim) 109 | 110 | dims = (/Lon_tdim,lat_tdim,z_tdim,iTimedim/) 111 | id = ncvdef (ncid,'dtemp_adv', NCFLOAT,4,dims,iret) 112 | name = 'Temperature tendency by advection'; unit = 'K/s' 113 | call dvcdf(ncid,id,name,60,unit,16,spval) 114 | 115 | dims = (/Lon_tdim,lat_tdim,z_tdim,iTimedim/) 116 | id = ncvdef (ncid,'dsalt_adv', NCFLOAT,4,dims,iret) 117 | name = 'Salinity tendency by advection'; unit = 'g/Kg/s' 118 | call dvcdf(ncid,id,name,60,unit,16,spval) 119 | 120 | dims = (/Lon_tdim,lat_tdim,z_tdim,iTimedim/) 121 | id = ncvdef (ncid,'dtemp_vmix', NCFLOAT,4,dims,iret) 122 | name = 'Temperature tendency by vert. mixing'; unit = 'K/s' 123 | call dvcdf(ncid,id,name,60,unit,16,spval) 124 | 125 | dims = (/Lon_tdim,lat_tdim,z_tdim,iTimedim/) 126 | id = ncvdef (ncid,'dsalt_vmix', NCFLOAT,4,dims,iret) 127 | name = 'Salinity tendency by vert. mixing'; unit = 'g/Kg/s' 128 | call dvcdf(ncid,id,name,60,unit,16,spval) 129 | 130 | dims = (/Lon_tdim,lat_tdim,z_tdim,iTimedim/) 131 | id = ncvdef (ncid,'dtemp_iso', NCFLOAT,4,dims,iret) 132 | name = 'Temperature tendency by isop. mixing'; unit = 'K/s' 133 | call dvcdf(ncid,id,name,60,unit,16,spval) 134 | 135 | dims = (/Lon_tdim,lat_tdim,z_tdim,iTimedim/) 136 | id = ncvdef (ncid,'dsalt_iso', NCFLOAT,4,dims,iret) 137 | name = 'Salinity tendency by isop. mixing'; unit = 'g/Kg/s' 138 | call dvcdf(ncid,id,name,60,unit,16,spval) 139 | 140 | 141 | call ncclos (ncid, iret) 142 | print'(a)',' done ' 143 | endif 144 | call fortran_barrier 145 | 146 | 147 | end subroutine init_diag_snap_tendency -------------------------------------------------------------------------------- /for_src/diagnostics/diag_snap_tracer.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | subroutine init_snap_cdf_tracer 5 | !======================================================================= 6 | ! initialize NetCDF snapshot file for tracer variables 7 | !======================================================================= 8 | use main_module 9 | use tracer_module 10 | use diagnostics_module 11 | implicit none 12 | include "netcdf.inc" 13 | integer :: ncid,iret 14 | integer :: lon_tdim,lon_udim,itimedim 15 | integer :: lat_tdim,lat_udim,id,z_tdim,z_udim 16 | integer :: dims(4),n 17 | character :: name*32, unit*16 18 | real*8, parameter :: spval = -1.0d33 19 | 20 | if (my_pe==0) print'(a)',' preparing file pyOM_tracer.cdf' 21 | 22 | call def_grid_cdf('pyOM_tracer.cdf') 23 | 24 | if (my_pe==0) then 25 | iret=nf_open('pyOM_tracer.cdf',NF_WRITE, ncid) 26 | iret=nf_set_fill(ncid, NF_NOFILL, iret) 27 | call ncredf(ncid, iret) 28 | iret=nf_inq_dimid(ncid,'xt',lon_tdim) 29 | iret=nf_inq_dimid(ncid,'xu',lon_udim) 30 | iret=nf_inq_dimid(ncid,'yt',lat_tdim) 31 | iret=nf_inq_dimid(ncid,'yu',lat_udim) 32 | iret=nf_inq_dimid(ncid,'zt',z_tdim) 33 | iret=nf_inq_dimid(ncid,'zu',z_udim) 34 | iret=nf_inq_dimid(ncid,'Time',itimedim) 35 | 36 | do n=1,n_trac 37 | write(name, '("trac",i3)') n; call replace_space_zero(name) 38 | dims = (/Lon_tdim,lat_tdim,z_udim,iTimedim/) 39 | id = ncvdef (ncid,name, NCFLOAT,4,dims,iret) 40 | name = 'passive tracer'; unit = ' ' 41 | call dvcdf(ncid,id,name,32,unit,16,spval) 42 | 43 | write(name, '("trac",i3,"_sflux")') n; call replace_space_zero(name) 44 | dims = (/Lon_tdim,lat_tdim,iTimedim,1/) 45 | id = ncvdef (ncid,name, NCFLOAT,3,dims,iret) 46 | name = 'surface flux'; unit = ' ' 47 | call dvcdf(ncid,id,name,len_trim(name),unit,16,spval) 48 | enddo 49 | call ncclos (ncid, iret) 50 | print'(a)',' done ' 51 | endif 52 | call fortran_barrier 53 | end subroutine init_snap_cdf_tracer 54 | 55 | 56 | subroutine diag_snap_tracer 57 | !======================================================================= 58 | ! write tracer variables to NetCDF snapshot file 59 | !======================================================================= 60 | use main_module 61 | use tracer_module 62 | use diagnostics_module 63 | implicit none 64 | include "netcdf.inc" 65 | integer :: ncid,iret,n 66 | real*8 :: bloc(nx,ny),fxa 67 | integer :: itdimid,ilen,itimeid,id,k 68 | real*8, parameter :: spval = -1.0d33 69 | character :: name*32 70 | 71 | if (my_pe == 0 ) then 72 | iret=nf_open('pyOM_tracer.cdf',NF_WRITE,ncid) 73 | print'(a)',' writing to file pyOM_tracer.cdf' 74 | iret=nf_set_fill(ncid, NF_NOFILL, iret) 75 | iret=nf_inq_dimid(ncid,'Time',itdimid) 76 | iret=nf_inq_dimlen(ncid, itdimid,ilen) 77 | ilen=ilen+1 78 | fxa = itt*dt_tracer/86400.0 79 | iret=nf_inq_varid(ncid,'Time',itimeid) 80 | iret= nf_put_vara_double(ncid,itimeid,(/ilen/),(/1/),(/fxa/)) 81 | call ncclos (ncid, iret) 82 | endif 83 | call fortran_barrier 84 | 85 | if (my_pe == 0 ) then 86 | iret=nf_open('pyOM_tracer.cdf',NF_WRITE,ncid) 87 | iret=nf_inq_dimid(ncid,'Time',itdimid) 88 | iret=nf_inq_dimlen(ncid, itdimid,ilen) 89 | endif 90 | 91 | do n=1,n_trac 92 | bloc(is_pe:ie_pe,js_pe:je_pe) = forc_trac_surface(is_pe:ie_pe,js_pe:je_pe,n) 93 | where( maskW(is_pe:ie_pe,js_pe:je_pe,nz) == 0.) bloc(is_pe:ie_pe,js_pe:je_pe) = spval 94 | call pe0_recv_2D(nx,ny,bloc) 95 | if (my_pe==0) then 96 | write(name, '("trac",i3,"_sflux")') n; call replace_space_zero(name) 97 | iret=nf_inq_varid(ncid,name,id) 98 | iret= nf_put_vara_double(ncid,id,(/1,1,ilen/), (/nx,ny,1/),bloc) 99 | endif 100 | enddo 101 | ! 3D fields 102 | 103 | do k=1,nz 104 | do n=1,n_trac 105 | bloc(is_pe:ie_pe,js_pe:je_pe) = trac(is_pe:ie_pe,js_pe:je_pe,k,tau,n) 106 | where( maskW(is_pe:ie_pe,js_pe:je_pe,k) == 0.) bloc(is_pe:ie_pe,js_pe:je_pe) = spval 107 | call pe0_recv_2D(nx,ny,bloc) 108 | if (my_pe == 0 ) then 109 | write(name, '("trac",i3)') n; call replace_space_zero(name) 110 | iret=nf_inq_varid(ncid,name,id) 111 | iret= nf_put_vara_double(ncid,id,(/1,1,k,ilen/), (/nx,ny,1,1/),bloc) 112 | endif 113 | enddo 114 | enddo 115 | 116 | if (my_pe==0) iret = nf_close (ncid) 117 | end subroutine diag_snap_tracer 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /for_src/diagnostics/diagnostics_module.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | module diagnostics_module 4 | implicit none 5 | !--------------------------------------------------------------------------------- 6 | ! diagnostic options 7 | !--------------------------------------------------------------------------------- 8 | logical :: enable_diag_ts_monitor = .false. ! enable time step monitor 9 | logical :: enable_diag_energy = .false. ! enable diagnostics for energy 10 | logical :: enable_diag_averages = .false. ! enable time averages 11 | logical :: enable_diag_variances = .false. ! enable time variances 12 | logical :: enable_diag_snapshots = .false. ! enable snapshots 13 | logical :: enable_diag_overturning = .false. ! enable isopycnal overturning diagnostic 14 | logical :: enable_diag_tracer_content= .false. ! enable tracer content and variance monitor 15 | logical :: enable_diag_particles = .false. ! enable integration of particles 16 | logical :: enable_diag_qg_streamfct = .false. ! enable quasi-geostrophic streamfct. diagnostics 17 | logical :: enable_diag_snap_fluxes = .false. ! enable advective and diffusive flux diagnostics 18 | logical :: enable_diag_snap_tendency = .false. ! enable temp/salt tendency diagnostics 19 | logical :: enable_diag_parallel_snap = .false. ! enable parallel output 20 | logical :: enable_diag_chunks_snap = .false. ! enable snapshot output in chunks per processor 21 | logical :: enable_diag_opt_balance = .false. ! enable optimal balance diagnostic 22 | 23 | real*8 :: snapint=0. ! intervall between snapshots to be written in seconds 24 | real*8 :: aveint=0. ! intervall between time averages to be written in seconds 25 | real*8 :: varint=0. ! intervall between time variances to be written in seconds 26 | real*8 :: energint=0. ! intervall between energy diag to be written in seconds 27 | real*8 :: energfreq=0.! diagnosing every energfreq seconds 28 | real*8 :: ts_monint=0.! intervall between time step monitor in seconds 29 | real*8 :: avefreq=0. ! averaging every ave_freq seconds 30 | real*8 :: varfreq=0. ! calculating variances every var_freq seconds 31 | real*8 :: overint=0. ! intervall between overturning averages to be written in seconds 32 | real*8 :: overfreq=0. ! averaging overturning every ave_freq seconds 33 | real*8 :: trac_cont_int=0.! intervall between tracer content monitor in seconds 34 | real*8 :: particles_int=0. ! intervall 35 | real*8 :: opt_balance_int = 0. ! intervall 36 | end module diagnostics_module 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /for_src/eke/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: eke_module.o eke.o 5 | 6 | eke_module.o: eke_module.f90 ../main/main_module.o 7 | $(F90) $(F90FLAGS) -I../main -c eke_module.f90 8 | eke.o: eke.f90 ../main/main_module.o \ 9 | ../isoneutral/isoneutral_module.o eke_module.o 10 | $(F90) $(F90FLAGS) -I../main -I../isoneutral -c eke.f90 11 | clean : 12 | rm -f *.o *.mod 13 | 14 | -------------------------------------------------------------------------------- /for_src/eke/eke_module.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | module eke_module 4 | implicit none 5 | !--------------------------------------------------------------------------------- 6 | ! EKE model 7 | !--------------------------------------------------------------------------------- 8 | logical :: enable_eke = .false. 9 | real*8, allocatable :: deke(:,:,:,:) ! tendency due to advection using Adam Bashforth 10 | real*8, allocatable :: eke(:,:,:,:) ! meso-scale energy in m^2/s^2 11 | real*8, allocatable :: sqrteke(:,:,:) ! square root of EKE 12 | real*8, allocatable :: L_rossby(:,:) ! Rossby radius 13 | real*8, allocatable :: eke_len(:,:,:) ! eddy length scale 14 | real*8, allocatable :: eke_diss_iw(:,:,:) ! Dissipation of EKE to internal waves 15 | real*8, allocatable :: eke_diss_tke(:,:,:) ! Dissipation of EKE to TKE 16 | real*8, allocatable :: L_rhines(:,:,:) ! Rhines scale 17 | real*8 :: eke_lmin = 100.0 ! minimal length scale in m 18 | real*8 :: eke_c_k = 1.0 19 | real*8 :: eke_cross = 1.0 ! Parameter for EKE model 20 | real*8 :: eke_crhin = 1.0 ! Parameter for EKE model 21 | real*8 :: eke_c_eps = 1.0 ! Parameter for EKE model 22 | real*8 :: eke_k_max = 1d4 ! maximum of K_gm 23 | real*8 :: alpha_eke = 1.0 ! factor for vertical friction 24 | logical :: enable_eke_superbee_advection = .false. 25 | logical :: enable_eke_dst3_advection = .false. 26 | logical :: enable_eke_AB_time_stepping = .true. 27 | logical :: enable_eke_isopycnal_diffusion = .false. ! use K_gm also for isopycnal diffusivity 28 | 29 | real*8, allocatable :: eke_topo_hrms(:,:), eke_topo_lam(:,:), hrms_k0(:,:) 30 | real*8, allocatable :: eke_c_lee(:,:) 31 | real*8, allocatable :: c_Ri_diss(:,:,:) 32 | real*8, allocatable :: eke_lee_flux(:,:),eke_bot_flux(:,:) 33 | logical :: enable_eke_leewave_dissipation = .false. 34 | real*8 :: eke_c_lee0 = 1.0 35 | real*8 :: eke_Ri0 = 200.0 36 | real*8 :: eke_Ri1 = 50.0 37 | real*8 :: eke_int_diss0 = 1./(20*86400.) 38 | real*8 :: kappa_EKE0 = 0.1 39 | real*8 :: eke_r_bot = 0.0 ! bottom friction coefficient 40 | real*8 :: eke_hrms_k0_min = 0.0 ! minmal value for bottom roughness parameter 41 | 42 | end module eke_module 43 | 44 | subroutine allocate_eke_module 45 | use main_module 46 | use eke_module 47 | if (enable_eke) then 48 | allocate(deke(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,3) );deke = 0.0 49 | allocate( eke(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,3) ); eke = 0.0 50 | allocate( sqrteke(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); sqrteke = 0 51 | allocate( L_rossby(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); L_rossby = 0.0 52 | allocate( eke_len(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); eke_len = 0.0 53 | allocate( eke_diss_iw(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); eke_diss_iw = 0.0 54 | allocate( eke_diss_tke(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); eke_diss_tke = 0.0 55 | allocate( L_rhines(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); L_rhines = 0.0 56 | allocate( eke_bot_flux(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); eke_bot_flux = 0.0 57 | if (enable_eke_leewave_dissipation ) then 58 | allocate( eke_topo_hrms(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); eke_topo_hrms = 0.0 59 | allocate( eke_topo_lam(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); eke_topo_lam = 0.0 60 | allocate( hrms_k0(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); hrms_k0 = 0.0 61 | allocate( eke_c_lee(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); eke_c_lee = 0.0 62 | allocate( eke_lee_flux(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); eke_lee_flux = 0.0 63 | allocate( c_Ri_diss(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); c_Ri_diss = 0.0 64 | endif 65 | endif 66 | end subroutine allocate_eke_module 67 | 68 | 69 | -------------------------------------------------------------------------------- /for_src/etc/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: timing_module.o py_stuff.o 5 | 6 | check_timing : check_timing.f90 timing_module.o 7 | $(F90) check_timing.f90 timing_module.o $(F90FLAGS) \ 8 | -o ../../bin/check_timing.x 9 | 10 | clean : 11 | rm -f *.o *.mod 12 | 13 | 14 | timing_module.o: timing_module.f90 15 | $(F90) $(F90FLAGS) -c timing_module.f90 16 | py_stuff.o: py_stuff.f90 17 | $(F90) $(F90FLAGS) -c py_stuff.f90 18 | 19 | -------------------------------------------------------------------------------- /for_src/etc/check_timing.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | program check_timing 7 | use timing_module 8 | implicit none 9 | integer :: i,j 10 | real :: fxa 11 | real,external :: timing_secs2 12 | 13 | call tic('loop') 14 | do j=1,100000 15 | do i=1,100000 16 | fxa = sin(2.7*3.1415)*cos(2.88*3.1415)+1.2 17 | enddo 18 | enddo 19 | print*,' fxa = ',fxa 20 | call toc('loop') 21 | print*,' ok done' 22 | 23 | call get_timing('loop',fxa) 24 | print*,' costs = ',fxa,' s' 25 | call get_timing('tictoc',fxa) 26 | print*,' tictoc = ',fxa,' s' 27 | call get_timing('test',fxa) 28 | print*,' test = ',fxa,' s' 29 | 30 | print*,' costs = ',timing_secs('loop'),' s' 31 | print*,' tictoc = ',timing_secs('tictoc'),' s' 32 | print*,' test = ',timing_secs('test'),' s' 33 | 34 | end program 35 | 36 | 37 | -------------------------------------------------------------------------------- /for_src/etc/py_stuff.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | subroutine panic_snap 5 | end subroutine panic_snap 6 | 7 | -------------------------------------------------------------------------------- /for_src/etc/timing_module.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | !======================================================================= 4 | ! timing module 5 | ! stores elapsed time between calls of tic/toc subroutines 6 | ! there is the need to specify a time measurement routine below 7 | !======================================================================= 8 | 9 | module timing_module 10 | implicit none 11 | integer, parameter, private :: max_counter = 1000 12 | integer,private :: act_counter = 0 13 | character (len=80),private :: ref_counter(max_counter) 14 | real,private :: counter(0:max_counter)=0,now(0:max_counter)=0 15 | 16 | contains 17 | 18 | real function elapsed() 19 | implicit none 20 | ! 21 | ! elapsed should give the elasped cpu (user) time 22 | ! a function which gives elapsed cpu time is needed here 23 | ! 24 | ! this works for linux and many other unix machines 25 | !real (kind=4) :: tarray(2),fxa 26 | !call etime(tarray,fxa) 27 | !elapsed = tarray(1) 28 | real (kind=4) :: fxa 29 | call cpu_time(fxa) 30 | elapsed = fxa 31 | end function elapsed 32 | 33 | 34 | subroutine tic(ref) 35 | implicit none 36 | character (len=*), intent(in) :: ref 37 | integer :: n,len 38 | now(0)=elapsed() 39 | len=len_trim(ref) 40 | do n=1,act_counter 41 | if (ref(1:len) == ref_counter(n)(1:len) ) then 42 | now(n) = now(0) 43 | counter(0) = counter(0)+elapsed()-now(0) 44 | return 45 | endif 46 | enddo 47 | if (act_counter == max_counter ) then 48 | print*,' ERROR:' 49 | print*,' number of counters exceeds max_counter = ',max_counter 50 | print*,' in tic' 51 | print*,' ref = ',ref 52 | endif 53 | act_counter = act_counter + 1 54 | ref_counter(act_counter) = ref 55 | now(act_counter) = elapsed() 56 | counter(0) = counter(0)+elapsed()-now(0) 57 | end subroutine tic 58 | 59 | subroutine toc(ref) 60 | implicit none 61 | character (len=*), intent(in) :: ref 62 | integer :: n,len 63 | now(0)=elapsed() 64 | len=len_trim(ref) 65 | do n=1,act_counter 66 | if (ref(1:len) == ref_counter(n)(1:len) ) then 67 | counter(n) = counter(n)+now(0)-now(n) 68 | counter(0) = counter(0)+elapsed()-now(0) 69 | return 70 | endif 71 | enddo 72 | print*,' ERROR:' 73 | print*,' cannot find ',ref(1:len),' in my list' 74 | print*,' in toc' 75 | end subroutine toc 76 | 77 | real function timing_secs(ref) 78 | implicit none 79 | character (len=*), intent(in) :: ref 80 | integer :: n,len 81 | if (ref=='tictoc') then 82 | timing_secs = counter(0) 83 | return 84 | endif 85 | len=len_trim(ref) 86 | do n=1,act_counter 87 | if (ref(1:len) == ref_counter(n)(1:len) ) then 88 | timing_secs = counter(n) 89 | return 90 | endif 91 | enddo 92 | timing_secs = -1. 93 | end function timing_secs 94 | 95 | 96 | subroutine get_timing(ref,secs) 97 | implicit none 98 | character (len=*), intent(in) :: ref 99 | real,intent(out) :: secs 100 | integer :: n,len 101 | if (ref=='tictoc') then 102 | secs = counter(0) 103 | return 104 | endif 105 | len=len_trim(ref) 106 | do n=1,act_counter 107 | if (ref(1:len) == ref_counter(n)(1:len) ) then 108 | secs = counter(n) 109 | return 110 | endif 111 | enddo 112 | print*,' ERROR:' 113 | print*,' cannot find ',ref(1:len),' in my list' 114 | print*,' in get_timing' 115 | secs = -1. 116 | end subroutine 117 | 118 | 119 | 120 | end module timing_module 121 | 122 | -------------------------------------------------------------------------------- /for_src/external/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: solve_pressure.o streamfct_init.o solve_streamfct.o island_module.o 5 | 6 | clean : 7 | rm -f *.o *.mod 8 | 9 | island_module.o: island_module.f90 10 | $(F90) $(F90FLAGS) -c island_module.f90 11 | solve_pressure.o: solve_pressure.f90 ../main/main_module.o 12 | $(F90) $(F90FLAGS) -I../main -c solve_pressure.f90 13 | streamfct_init.o: streamfct_init.f90 ../main/main_module.o 14 | $(F90) $(F90FLAGS) -I../main -c streamfct_init.f90 15 | solve_streamfct.o: solve_streamfct.f90 ../main/main_module.o 16 | $(F90) $(F90FLAGS) -I../main -c solve_streamfct.f90 17 | 18 | -------------------------------------------------------------------------------- /for_src/idemix/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: idemix_module.o idemix.o idemix_low_mode.o idemix3.o\ 5 | idemix_spectral.o idemix_group_vel.o idemix_friction.o idemix_leewaves.o 6 | 7 | clean : 8 | rm -f *.o *.mod 9 | 10 | idemix_module.o : idemix_module.f90 ../main/main_module.o 11 | $(F90) $(F90FLAGS) -I../main -c idemix_module.f90 12 | idemix.o: idemix.f90 ../main/main_module.o ../eke/eke_module.o ../etc/timing_module.o idemix_module.o 13 | $(F90) $(F90FLAGS) -I../main -I../eke -I../etc -c idemix.f90 14 | idemix_low_mode.o: idemix_low_mode.f90 ../main/main_module.o idemix_module.o 15 | $(F90) $(F90FLAGS) -I../main -c idemix_low_mode.f90 16 | idemix_spectral.o: idemix_spectral.f90 ../main/main_module.o idemix_module.o 17 | $(F90) $(F90FLAGS) -I../main -c idemix_spectral.f90 18 | idemix_group_vel.o: idemix_group_vel.f90 ../main/main_module.o idemix_module.o 19 | $(F90) $(F90FLAGS) -I../main -c idemix_group_vel.f90 20 | idemix3.o : idemix3.f90 ../main/main_module.o idemix_module.o 21 | $(F90) $(F90FLAGS) -I../main -c idemix3.f90 22 | idemix_friction.o : idemix_friction.f90 ../main/main_module.o idemix_module.o 23 | $(F90) $(F90FLAGS) -I../main -c idemix_friction.f90 24 | 25 | idemix_leewaves.o : idemix_leewaves.f90 ../main/main_module.o idemix_module.o 26 | $(F90) $(F90FLAGS) -I../main -c idemix_leewaves.f90 27 | -------------------------------------------------------------------------------- /for_src/isoneutral/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: isoneutral_module.o isoneutral_diffusion.o \ 5 | isoneutral_friction.o isoneutral.o isoneutral_ml.o 6 | 7 | clean : 8 | rm -f *.o *.mod 9 | 10 | isoneutral_module.o: isoneutral_module.f90 ../main/main_module.o 11 | $(F90) $(F90FLAGS) -I../main -c isoneutral_module.f90 12 | isoneutral.o: isoneutral.f90 ../main/main_module.o isoneutral_module.o 13 | $(F90) $(F90FLAGS) -I../main -c isoneutral.f90 14 | isoneutral_diffusion.o: isoneutral_diffusion.f90 \ 15 | ../main/main_module.o isoneutral_module.o 16 | $(F90) $(F90FLAGS) -I../main -c isoneutral_diffusion.f90 17 | isoneutral_friction.o: isoneutral_friction.f90 ../eke/eke_module.o \ 18 | ../main/main_module.o isoneutral_module.o 19 | $(F90) $(F90FLAGS) -I../main -I../eke -c isoneutral_friction.f90 20 | isoneutral_ml.o: isoneutral_ml.f90 ../main/main_module.o isoneutral_module.o 21 | $(F90) $(F90FLAGS) -I../main -c isoneutral_ml.f90 22 | 23 | -------------------------------------------------------------------------------- /for_src/isoneutral/isoneutral_friction.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | subroutine isoneutral_friction 6 | !======================================================================= 7 | ! vertical friction using TEM formalism for eddy driven velocity 8 | !======================================================================= 9 | use main_module 10 | use isoneutral_module 11 | use eke_module 12 | implicit none 13 | integer :: i,j,k,ks 14 | real*8 :: a_tri(nz),b_tri(nz),c_tri(nz),d_tri(nz),delta(nz),fxa 15 | real*8 :: diss(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) 16 | real*8 :: aloc(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) 17 | 18 | if (enable_implicit_vert_friction) then 19 | aloc=u(:,:,:,taup1) 20 | else 21 | aloc=u(:,:,:,tau) 22 | endif 23 | 24 | ! implicit vertical friction of zonal momentum by GM 25 | do j=js_pe-1,je_pe 26 | do i=is_pe-1,ie_pe 27 | ks=max(kbot(i,j),kbot(i+1,j)) 28 | if (ks>0) then 29 | do k=ks,nz-1 30 | fxa = 0.5*(kappa_gm(i,j,k)+kappa_gm(i+1,j,k)) 31 | delta(k) = dt_mom/dzw(k)*fxa*maskU(i,j,k+1)*maskU(i,j,k) 32 | enddo 33 | delta(nz)=0.0 34 | a_tri(ks)=0.0 35 | do k=ks+1,nz 36 | a_tri(k) = - delta(k-1)/dzt(k) 37 | enddo 38 | b_tri(ks) = 1+ delta(ks)/dzt(ks) 39 | do k=ks+1,nz-1 40 | b_tri(k) = 1+ delta(k)/dzt(k) + delta(k-1)/dzt(k) 41 | enddo 42 | b_tri(nz) = 1+ delta(nz-1)/dzt(nz) 43 | do k=ks,nz-1 44 | c_tri(k) = - delta(k)/dzt(k) 45 | enddo 46 | c_tri(nz)=0.0 47 | d_tri(ks:nz)=aloc(i,j,ks:nz)! A u = d 48 | call solve_tridiag(a_tri(ks:nz),b_tri(ks:nz),c_tri(ks:nz),d_tri(ks:nz),u(i,j,ks:nz,taup1),nz-ks+1) 49 | du_mix(i,j,ks:nz)=du_mix(i,j,ks:nz)+ (u(i,j,ks:nz,taup1)-aloc(i,j,ks:nz))/dt_mom 50 | endif 51 | enddo 52 | enddo 53 | 54 | if (enable_conserve_energy) then 55 | ! diagnose dissipation 56 | do k=1,nz-1 57 | do j=js_pe-1,je_pe 58 | do i=is_pe-1,ie_pe 59 | fxa = 0.5*(kappa_gm(i,j,k)+kappa_gm(i+1,j,k)) 60 | flux_top(i,j,k)=fxa*(u(i,j,k+1,taup1)-u(i,j,k,taup1))/dzw(k)*maskU(i,j,k+1)*maskU(i,j,k) 61 | enddo 62 | enddo 63 | enddo 64 | do k=1,nz-1 65 | do j=js_pe-1,je_pe 66 | do i=is_pe-1,ie_pe 67 | diss(i,j,k) = (u(i,j,k+1,tau)-u(i,j,k,tau))*flux_top(i,j,k)/dzw(k) 68 | enddo 69 | enddo 70 | enddo 71 | diss(:,:,nz)=0.0 72 | call ugrid_to_tgrid(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,diss,diss) 73 | K_diss_gm = diss 74 | endif 75 | 76 | if (enable_implicit_vert_friction) then 77 | aloc=v(:,:,:,taup1) 78 | else 79 | aloc=v(:,:,:,tau) 80 | endif 81 | 82 | ! implicit vertical friction of meridional momentum by GM 83 | do j=js_pe-1,je_pe 84 | do i=is_pe-1,ie_pe 85 | ks=max(kbot(i,j),kbot(i,j+1)) 86 | if (ks>0) then 87 | do k=ks,nz-1 88 | fxa = 0.5*(kappa_gm(i,j,k)+kappa_gm(i,j+1,k)) 89 | delta(k) = dt_mom/dzw(k)*fxa*maskV(i,j,k+1)*maskV(i,j,k) 90 | enddo 91 | delta(nz)=0.0 92 | a_tri(ks)=0.0 93 | do k=ks+1,nz 94 | a_tri(k) = - delta(k-1)/dzt(k) 95 | enddo 96 | b_tri(ks) = 1+ delta(ks)/dzt(ks) 97 | do k=ks+1,nz-1 98 | b_tri(k) = 1+ delta(k)/dzt(k) + delta(k-1)/dzt(k) 99 | enddo 100 | b_tri(nz) = 1+ delta(nz-1)/dzt(nz) 101 | do k=ks,nz-1 102 | c_tri(k) = - delta(k)/dzt(k) 103 | enddo 104 | c_tri(nz)=0.0 105 | d_tri(ks:nz)=aloc(i,j,ks:nz) 106 | call solve_tridiag(a_tri(ks:nz),b_tri(ks:nz),c_tri(ks:nz),d_tri(ks:nz),v(i,j,ks:nz,taup1),nz-ks+1) 107 | dv_mix(i,j,ks:nz)=dv_mix(i,j,ks:nz)+ (v(i,j,ks:nz,taup1)-aloc(i,j,ks:nz))/dt_mom 108 | endif 109 | enddo 110 | enddo 111 | 112 | if (enable_conserve_energy) then 113 | ! diagnose dissipation 114 | do k=1,nz-1 115 | do j=js_pe-1,je_pe 116 | do i=is_pe-1,ie_pe 117 | fxa = 0.5*(kappa_gm(i,j,k)+kappa_gm(i,j+1,k)) 118 | flux_top(i,j,k)=fxa*(v(i,j,k+1,taup1)-v(i,j,k,taup1))/dzw(k)*maskV(i,j,k+1)*maskV(i,j,k) 119 | enddo 120 | enddo 121 | enddo 122 | do k=1,nz-1 123 | do j=js_pe-1,je_pe 124 | do i=is_pe-1,ie_pe 125 | diss(i,j,k) =(v(i,j ,k+1,tau)-v(i,j ,k,tau))*flux_top(i,j ,k)/dzw(k) 126 | enddo 127 | enddo 128 | enddo 129 | diss(:,:,nz)=0.0 130 | call vgrid_to_tgrid(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,diss,diss) 131 | K_diss_gm = K_diss_gm + diss 132 | endif 133 | 134 | end subroutine isoneutral_friction 135 | 136 | 137 | -------------------------------------------------------------------------------- /for_src/isoneutral/isoneutral_module.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | module isoneutral_module 5 | implicit none 6 | !--------------------------------------------------------------------------------- 7 | ! isopycnal mixing option 8 | !--------------------------------------------------------------------------------- 9 | logical :: enable_neutral_diffusion = .false. ! enable isopycnal mixing 10 | logical :: enable_skew_diffusion = .false. ! enable skew diffusion approach for eddy-driven velocities 11 | logical :: enable_TEM_friction = .false. ! TEM approach for eddy-driven velocities 12 | real*8, allocatable :: K_11(:,:,:) ! isopycnal mixing tensor component 13 | real*8, allocatable :: K_13(:,:,:) ! isopycnal mixing tensor component 14 | real*8, allocatable :: K_22(:,:,:) ! isopycnal mixing tensor component 15 | real*8, allocatable :: K_23(:,:,:) ! isopycnal mixing tensor component 16 | real*8, allocatable :: K_31(:,:,:) ! isopycnal mixing tensor component 17 | real*8, allocatable :: K_32(:,:,:) ! isopycnal mixing tensor component 18 | real*8, allocatable :: K_33(:,:,:) ! isopycnal mixing tensor component 19 | real*8, allocatable :: Ai_ez(:,:,:,:,:) ! 20 | real*8, allocatable :: Ai_nz(:,:,:,:,:) ! 21 | real*8, allocatable :: Ai_bx(:,:,:,:,:) ! 22 | real*8, allocatable :: Ai_by(:,:,:,:,:) ! 23 | real*8, allocatable :: B1_gm(:,:,:) ! zonal streamfunction (for diagnostic purpose only) 24 | real*8, allocatable :: B2_gm(:,:,:) ! meridional streamfunction (for diagnostic purpose only) 25 | real*8, allocatable :: K_gm(:,:,:) ! GM diffusivity in m^2/s, either constant or from EKE model 26 | real*8, allocatable :: kappa_gm(:,:,:) ! vertical viscosity due to skew diffusivity K_gm in m^2/s 27 | real*8, allocatable :: K_iso(:,:,:) ! along isopycnal diffusivity in m^2/s 28 | real*8 :: K_iso_0 = 0.0 ! constant for isopycnal diffusivity in m^2/s 29 | real*8 :: K_iso_steep = 0.0 ! lateral diffusivity for steep slopes in m^2/s 30 | real*8 :: K_gm_0 = 0.0 ! fixed value for K_gm which is set for no EKE model 31 | real*8 :: iso_dslope=0.0008 ! parameters controlling max allowed isopycnal slopes 32 | real*8 :: iso_slopec=0.001 ! parameters controlling max allowed isopycnal slopes 33 | 34 | ! mixed layer stuff 35 | real*8 :: ml_invTau = 1.6e-6 36 | real*8 :: ml_Ce = 0.9 37 | logical :: enable_ml_para = .false. 38 | logical :: enable_ml_para_stone = .true. 39 | logical :: enable_ml_HS_streamfct = .true. 40 | integer :: ml_algorithm = 1 ! algorithm to determine mixed layr 41 | real*8 :: ml_Nsqr_fac = 8d0 ! for mixed layer criterion 42 | real*8 :: ml_Delta_rho = 0.02 ! for mixed layer criterion 43 | real*8, allocatable :: B1_ml(:,:,:) ! zonal streamfunction 44 | real*8, allocatable :: B2_ml(:,:,:) ! meridional streamfunction 45 | real*8, allocatable :: K_ml(:,:,:) ! diffusivity 46 | real*8, allocatable :: u_ml(:,:,:) 47 | real*8, allocatable :: v_ml(:,:,:) 48 | real*8, allocatable :: w_ml(:,:,:) 49 | real*8, allocatable :: dtemp_ml(:,:,:) 50 | real*8, allocatable :: dsalt_ml(:,:,:) 51 | real*8, allocatable :: mld(:,:) 52 | real*8, allocatable :: Ri_ml(:,:) 53 | end module isoneutral_module 54 | 55 | 56 | 57 | 58 | subroutine allocate_isoneutral_module 59 | use main_module 60 | use isoneutral_module 61 | implicit none 62 | 63 | if (enable_neutral_diffusion) then 64 | allocate( K_11(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); K_11 = 0 65 | allocate( K_13(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); K_13 = 0 66 | allocate( K_22(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); K_22 = 0 67 | allocate( K_23(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); K_23 = 0 68 | allocate( K_31(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); K_31 = 0 69 | allocate( K_32(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); K_32 = 0 70 | allocate( K_33(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); K_33 = 0 71 | allocate( Ai_ez(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,0:1,0:1) ); Ai_ez = 0 72 | allocate( Ai_nz(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,0:1,0:1) ); Ai_nz = 0 73 | allocate( Ai_bx(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,0:1,0:1) ); Ai_bx = 0 74 | allocate( Ai_by(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,0:1,0:1) ); Ai_by = 0 75 | endif 76 | 77 | allocate( B1_gm(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); B1_gm = 0 78 | allocate( B2_gm(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); B2_gm = 0 79 | 80 | allocate( kappa_gm(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); kappa_gm = 0 81 | allocate( K_gm(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); K_gm = 0.0 82 | allocate( K_iso(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); K_iso = 0.0 83 | 84 | if (enable_ml_para) then 85 | allocate( Ri_ml(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); Ri_ml = 0 86 | allocate( mld(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); mld = 0 87 | allocate( B1_ml(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); B1_ml = 0 88 | allocate( B2_ml(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); B2_ml = 0 89 | allocate( K_ml(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); K_ml = 0 90 | allocate( u_ml(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); u_ml = 0 91 | allocate( v_ml(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); v_ml = 0 92 | allocate( w_ml(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); w_ml = 0 93 | allocate( dtemp_ml(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); dtemp_ml = 0 94 | allocate( dsalt_ml(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); dsalt_ml = 0 95 | endif 96 | end subroutine allocate_isoneutral_module 97 | -------------------------------------------------------------------------------- /for_src/main/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: main_module.o vertical_friction.o numerics.o diffusion.o bottom_friction.o \ 5 | harmonic_friction.o biharmonic_friction.o momentum.o momentum_advection.o \ 6 | vertical_velocity.o thermodynamics.o restart.o main.o 7 | 8 | clean : 9 | rm -f *.o *.mod 10 | 11 | main_module.o : main_module.f90 12 | $(F90) $(F90FLAGS) -c main_module.f90 13 | numerics.o: numerics.f90 main_module.o 14 | $(F90) $(F90FLAGS) -c numerics.f90 15 | vertical_friction.o: vertical_friction.f90 main_module.o 16 | $(F90) $(F90FLAGS) -c vertical_friction.f90 17 | bottom_friction.o: bottom_friction.f90 main_module.o 18 | $(F90) $(F90FLAGS) -c bottom_friction.f90 19 | harmonic_friction.o: harmonic_friction.f90 main_module.o 20 | $(F90) $(F90FLAGS) -c harmonic_friction.f90 21 | biharmonic_friction.o: biharmonic_friction.f90 main_module.o 22 | $(F90) $(F90FLAGS) -c biharmonic_friction.f90 23 | diffusion.o: diffusion.f90 main_module.o 24 | $(F90) $(F90FLAGS) -c diffusion.f90 25 | 26 | main.o: main.f90 main_module.o ../tke/tke_module.o ../eke/eke_module.o \ 27 | ../idemix/idemix_module.o ../diagnostics/diagnostics_module.o \ 28 | ../etc/timing_module.o 29 | $(F90) $(F90FLAGS) -I../tke -I../eke -I../idemix -I../diagnostics -I../etc -c main.f90 30 | 31 | time_step.o: time_step.f90 main_module.o 32 | $(F90) $(F90FLAGS) $(CDFFLAGS) -c time_step.f90 33 | 34 | momentum.o: momentum.f90 main_module.o ../isoneutral/isoneutral_module.o ../etc/timing_module.o \ 35 | ../idemix/idemix_module.o ../rossmix/rossmix_module.o ../rossmix2/rossmix2_module.o 36 | $(F90) $(F90FLAGS) -I../isoneutral -I../idemix -I../rossmix -I../rossmix2 -I../etc -c momentum.f90 37 | 38 | momentum_advection.o: momentum_advection.f90 main_module.o 39 | $(F90) $(F90FLAGS) -c momentum_advection.f90 40 | 41 | vertical_velocity.o: vertical_velocity.f90 main_module.o 42 | $(F90) $(F90FLAGS) -c vertical_velocity.f90 43 | 44 | thermodynamics.o: thermodynamics.f90 main_module.o \ 45 | ../isoneutral/isoneutral_module.o ../tke/tke_module.o \ 46 | ../density/density.o ../etc/timing_module.o ../rossmix/rossmix_module.o ../rossmix2/rossmix2_module.o 47 | $(F90) $(F90FLAGS) -I../isoneutral -I../etc -I../density -I../tke -I../rossmix -I../rossmix2 -c thermodynamics.f90 48 | 49 | restart.o: restart.f90 main_module.o ../tke/tke_module.o ../eke/eke_module.o \ 50 | ../idemix/idemix_module.o ../rossmix2/rossmix2_module.o ../biha_thk/biharmonic_thickness_module.o 51 | $(F90) $(F90FLAGS) -I../tke -I../eke -I../idemix -I../rossmix2 -I../biha_thk -c restart.f90 52 | 53 | -------------------------------------------------------------------------------- /for_src/main/momentum_advection.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | subroutine momentum_advection 6 | !======================================================================= 7 | ! Advection of momentum with second order which is energy conserving 8 | !======================================================================= 9 | use main_module 10 | implicit none 11 | integer :: i,j,k 12 | real*8 :: utr(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) 13 | real*8 :: vtr(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) 14 | real*8 :: wtr(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) 15 | 16 | 17 | !--------------------------------------------------------------------------------- 18 | ! Code from MITgcm 19 | !--------------------------------------------------------------------------------- 20 | 21 | ! uTrans(i,j) = u(i,j)*dyG(i,j)*drF(k) 22 | ! vTrans(i,j) = v(i,j)*dxG(i,j)*drF(k) 23 | 24 | ! fZon(i,j) = 0.25*( uTrans(i,j) + uTrans(i+1,j) ) *( u(i,j) + u(i+1,j) ) 25 | ! fMer(i,j) = 0.25*( vTrans(i,j) + vTrans(i-1,j) ) *( u(i,j) + u(i,j-1) ) 26 | 27 | ! gU(i,j,k,bi,bj) = - 28 | ! & *( ( fZon(i,j ) - fZon(i-1,j) ) 29 | ! & +( fMer(i,j+1) - fMer(i, j) ) 30 | ! & +( fVerUkp(i,j) - fVerUkm(i,j) ) 31 | ! & ) /drF(k) / rAw(i,j) 32 | 33 | 34 | ! fZon(i,j) = 0.25*( uTrans(i,j) + uTrans(i,j-1) ) *(v(i,j) + v(i-1,j) ) 35 | ! fMer(i,j) = 0.25*( vTrans(i,j) + vTrans(i,j+1) ) *(v(i,j) + v(i,j+1) ) 36 | 37 | ! gV(i,j,k,bi,bj) = -recip_drF(k)*recip_rAs(i,j,bi,bj) 38 | ! & *( ( fZon(i+1,j) - fZon(i,j ) ) 39 | ! & +( fMer(i, j) - fMer(i,j-1) ) 40 | ! & +( fVerVkp(i,j) - fVerVkm(i,j) ) 41 | ! & ) 42 | 43 | 44 | do j=js_pe-onx,je_pe+onx 45 | do i=is_pe-onx,ie_pe+onx 46 | utr(i,j,:) = dzt(:)*dyt(j)*u(i,j,:,tau)*maskU(i,j,:) 47 | vtr(i,j,:) = dzt(:)*cosu(j)*dxt(i)*v(i,j,:,tau)*maskV(i,j,:) 48 | wtr(i,j,:) = area_t(i,j)*w(i,j,:,tau)*maskW(i,j,:) 49 | enddo 50 | enddo 51 | 52 | !--------------------------------------------------------------------------------- 53 | ! for zonal momentum 54 | !--------------------------------------------------------------------------------- 55 | do j=js_pe,je_pe 56 | do i=is_pe-1,ie_pe 57 | flux_east(i,j,:) = 0.25*(u(i,j,:,tau)+u(i+1,j,:,tau))*(utr(i+1,j,:)+utr(i,j,:)) 58 | enddo 59 | enddo 60 | do j=js_pe-1,je_pe 61 | do i=is_pe,ie_pe 62 | flux_north(i,j,:) = 0.25*(u(i,j,:,tau)+u(i,j+1,:,tau))*(vtr(i+1,j,:)+vtr(i,j,:)) 63 | enddo 64 | enddo 65 | do k=1,nz-1 66 | do j=js_pe,je_pe 67 | do i=is_pe,ie_pe 68 | flux_top(i,j,k) = 0.25*(u(i,j,k+1,tau)+u(i,j,k,tau))*(wtr(i,j,k)+wtr(i+1,j,k)) 69 | enddo 70 | enddo 71 | enddo 72 | flux_top(:,:,nz)=0.0 73 | do j=js_pe,je_pe 74 | do i=is_pe,ie_pe 75 | du_adv(i,j,:) = - maskU(i,j,:)*( flux_east(i,j,:) -flux_east(i-1,j,:) & 76 | +flux_north(i,j,:)-flux_north(i,j-1,:))/(area_u(i,j)*dzt(:)) 77 | enddo 78 | enddo 79 | k=1; du_adv(:,:,k) = du_adv(:,:,k) - maskU(:,:,k)*flux_top(:,:,k)/(area_u(:,:)*dzt(k)) 80 | do k=2,nz 81 | du_adv(:,:,k) = du_adv(:,:,k) - maskU(:,:,k)*(flux_top(:,:,k)-flux_top(:,:,k-1))/(area_u(:,:)*dzt(k)) 82 | enddo 83 | !--------------------------------------------------------------------------------- 84 | ! for meridional momentum 85 | !--------------------------------------------------------------------------------- 86 | do j=js_pe,je_pe 87 | do i=is_pe-1,ie_pe 88 | flux_east(i,j,:) = 0.25*(v(i,j,:,tau)+v(i+1,j,:,tau))*(utr(i,j+1,:)+utr(i,j,:)) 89 | enddo 90 | enddo 91 | do j=js_pe-1,je_pe 92 | do i=is_pe,ie_pe 93 | flux_north(i,j,:) = 0.25*(v(i,j,:,tau)+v(i,j+1,:,tau))*(vtr(i,j+1,:)+vtr(i,j,:)) 94 | enddo 95 | enddo 96 | do k=1,nz-1 97 | do j=js_pe,je_pe 98 | do i=is_pe,ie_pe 99 | flux_top(i,j,k) = 0.25*(v(i,j,k+1,tau)+v(i,j,k,tau))*(wtr(i,j,k)+wtr(i,j+1,k)) 100 | enddo 101 | enddo 102 | enddo 103 | flux_top(:,:,nz)=0.0 104 | do j=js_pe,je_pe 105 | do i=is_pe,ie_pe 106 | dv_adv(i,j,:) = - maskV(i,j,:)*( flux_east(i,j,:) -flux_east(i-1,j,:) & 107 | +flux_north(i,j,:)-flux_north(i,j-1,:))/(area_v(i,j)*dzt(:)) 108 | enddo 109 | enddo 110 | k=1; dv_adv(:,:,k) = dv_adv(:,:,k) - maskV(:,:,k)*flux_top(:,:,k)/(area_v(:,:)*dzt(k)) 111 | do k=2,nz 112 | dv_adv(:,:,k) = dv_adv(:,:,k) - maskV(:,:,k)*(flux_top(:,:,k)-flux_top(:,:,k-1))/(area_v(:,:)*dzt(k)) 113 | enddo 114 | 115 | 116 | if (.not. enable_hydrostatic) then 117 | !--------------------------------------------------------------------------------- 118 | ! for vertical momentum 119 | !--------------------------------------------------------------------------------- 120 | do k=1,nz 121 | do j=js_pe,je_pe 122 | do i=is_pe-1,ie_pe 123 | flux_east(i,j,k) = 0.5*(w(i,j,k,tau)+w(i+1,j,k,tau))*(u(i,j,k,tau)+u(i,j,min(nz,k+1),tau))*0.5*maskW(i+1,j,k)*maskW(i,j,k) 124 | enddo 125 | enddo 126 | enddo 127 | do k=1,nz 128 | do j=js_pe-1,je_pe 129 | do i=is_pe,ie_pe 130 | flux_north(i,j,k) = 0.5*(w(i,j,k,tau)+w(i,j+1,k,tau))* & 131 | (v(i,j,k,tau)+v(i,j,min(nz,k+1),tau))*0.5*maskW(i,j+1,k)*maskW(i,j,k)*cosu(j) 132 | enddo 133 | enddo 134 | enddo 135 | do k=1,nz-1 136 | do j=js_pe,je_pe 137 | do i=is_pe,ie_pe 138 | flux_top(i,j,k) = 0.5*(w(i,j,k+1,tau)+w(i,j,k,tau))*(w(i,j,k,tau)+w(i,j,k+1,tau))*0.5*maskW(i,j,k+1)*maskW(i,j,k) 139 | enddo 140 | enddo 141 | enddo 142 | flux_top(:,:,nz)=0.0 143 | do j=js_pe,je_pe 144 | do i=is_pe,ie_pe 145 | dw_adv(i,j,:)= maskW(i,j,:)* (-( flux_east(i,j,:)- flux_east(i-1,j,:))/(cost(j)*dxt(i)) & 146 | -(flux_north(i,j,:)- flux_north(i,j-1,:))/(cost(j)*dyt(j)) ) 147 | enddo 148 | enddo 149 | k=1; dw_adv(:,:,k) = dw_adv(:,:,k) - maskW(:,:,k)*flux_top(:,:,k)/dzw(k) 150 | do k=2,nz 151 | dw_adv(:,:,k) = dw_adv(:,:,k) - maskW(:,:,k)*(flux_top(:,:,k)-flux_top(:,:,k-1))/dzw(k) 152 | enddo 153 | endif 154 | 155 | end subroutine momentum_advection 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /for_src/main/time_step.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | program time_step 9 | !======================================================================= 10 | ! just do one time step for Machenhauer method 11 | !======================================================================= 12 | use main_module 13 | implicit none 14 | integer :: ierr,iargc 15 | character (len=80) :: arg 16 | !--------------------------------------------------------------------------------- 17 | ! Initialize MPI setting 18 | !--------------------------------------------------------------------------------- 19 | call mpi_init(ierr) 20 | call my_mpi_init(my_comm) 21 | 22 | n_pes_i = 1; n_pes_j = 1 23 | if (n_pes>1) then 24 | if (iargc() < 2) then 25 | call halt_stop(' not enough command line input') 26 | endif 27 | call getarg(1,arg); read(arg,*) n_pes_i 28 | call getarg(2,arg); read(arg,*) n_pes_j 29 | if (my_pe==0) print'(/a,i4,a,i4,a)','using ',n_pes_i,' x ',n_pes_j ,' PEs' 30 | endif 31 | !-------------------------------------------------------------- 32 | ! allocate everything 33 | !-------------------------------------------------------------- 34 | call set_parameter 35 | call pe_decomposition 36 | call allocate_main_module 37 | !-------------------------------------------------------------- 38 | ! Grid 39 | !-------------------------------------------------------------- 40 | call set_grid 41 | call calc_grid 42 | !-------------------------------------------------------------- 43 | ! topography 44 | !-------------------------------------------------------------- 45 | kbot=1 46 | call calc_topo 47 | !-------------------------------------------------------------- 48 | ! initial condition and forcing 49 | !-------------------------------------------------------------- 50 | call set_initial_conditions 51 | call calc_initial_conditions 52 | 53 | call tendencies 54 | 55 | 56 | call mpi_finalize(ierr) 57 | end program time_step 58 | 59 | 60 | 61 | 62 | 63 | 64 | subroutine tendencies 65 | use main_module 66 | implicit none 67 | include "netcdf.inc" 68 | integer :: ncid,iret,id,xdim,ydim,zdim,npe 69 | real*8 :: alpha,get_drhodT 70 | 71 | 72 | call momentum_advection 73 | call advect_tracer(is_pe-onx,ie_pe+onx,js_pe-onx,je_pe+onx,nz,temp(:,:,:,tau),dtemp(:,:,:,tau)) 74 | alpha = get_drhodT(35d0,5d0,0d0) 75 | ! T=-B/grav/alpha*rho_0 76 | dtemp = -dtemp*grav*alpha/rho_0 77 | 78 | if (my_pe==0) then 79 | ncid = nccre ('machenhauer1.cdf', NCCLOB, iret) 80 | iret=nf_set_fill(ncid, NF_NOFILL, iret) 81 | xdim = ncddef(ncid, 'x', nx, iret) 82 | ydim = ncddef(ncid, 'y', ny, iret) 83 | zdim = ncddef(ncid, 'z', nz, iret) 84 | id = ncvdef (ncid,'du', NCFLOAT,3,(/xdim,ydim,zdim/),iret) 85 | id = ncvdef (ncid,'dv', NCFLOAT,3,(/xdim,ydim,zdim/),iret) 86 | id = ncvdef (ncid,'db', NCFLOAT,3,(/xdim,ydim,zdim/),iret) 87 | call ncclos (ncid, iret) 88 | endif 89 | 90 | do npe = 0,n_pes-1 91 | if (my_pe==npe) then 92 | iret=nf_open('machenhauer1.cdf',NF_WRITE,ncid) 93 | iret=nf_inq_varid(ncid,'du',id) 94 | iret= nf_put_vara_double(ncid,id,(/is_pe,js_pe,1/),(/i_blk,j_blk,nz/),du_adv(is_pe:ie_pe,js_pe:je_pe,:)) 95 | iret=nf_inq_varid(ncid,'dv',id) 96 | iret= nf_put_vara_double(ncid,id,(/is_pe,js_pe,1/),(/i_blk,j_blk,nz/),dv_adv(is_pe:ie_pe,js_pe:je_pe,:)) 97 | iret=nf_inq_varid(ncid,'db',id) 98 | iret= nf_put_vara_double(ncid,id,(/is_pe,js_pe,1/),(/i_blk,j_blk,nz/),dtemp(is_pe:ie_pe,js_pe:je_pe,:,tau)) 99 | call ncclos (ncid, iret) 100 | endif 101 | call fortran_barrier() 102 | enddo 103 | 104 | end subroutine tendencies 105 | 106 | -------------------------------------------------------------------------------- /for_src/main/vertical_velocity.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | subroutine vertical_velocity 6 | !======================================================================= 7 | ! vertical velocity from continuity : 8 | ! \int_0^z w_z dz =w(z)-w(0) = - \int dz (u_x +v_y) 9 | ! w(z)=-int dz u_x + v_y 10 | !======================================================================= 11 | use main_module 12 | implicit none 13 | integer :: i,j,k 14 | ! integrate from bottom to surface to see error in w 15 | k=1 16 | do j=js_pe-onx+1,je_pe+onx 17 | do i=is_pe-onx+1,ie_pe+onx 18 | w(i,j,k,taup1) =-maskW(i,j,k)*dzt(k)* & 19 | (( u(i,j,k,taup1)- u(i-1,j,k,taup1))/(cost(j)*dxt(i)) & 20 | +(cosu(j)*v(i,j,k,taup1)-cosu(j-1)*v(i,j-1,k,taup1))/(cost(j)*dyt(j)) ) 21 | enddo 22 | enddo 23 | do k=2,nz 24 | do j=js_pe-onx+1,je_pe+onx 25 | do i=is_pe-onx+1,ie_pe+onx 26 | w(i,j,k,taup1) = w(i,j,k-1,taup1)-maskW(i,j,k)*dzt(k)* & 27 | (( u(i,j,k,taup1) -u(i-1,j,k,taup1))/(cost(j)*dxt(i)) & 28 | +(cosu(j)*v(i,j,k,taup1)-cosu(j-1)*v(i,j-1,k,taup1))/(cost(j)*dyt(j)) ) 29 | enddo 30 | enddo 31 | enddo 32 | end subroutine vertical_velocity 33 | 34 | 35 | 36 | 37 | subroutine vertical_velocity_tau(ntau) 38 | !======================================================================= 39 | ! vertical velocity from continuity : 40 | ! \int_0^z w_z dz =w(z)-w(0) = - \int dz (u_x +v_y) 41 | ! w(z)=-int dz u_x + v_y 42 | !======================================================================= 43 | use main_module 44 | implicit none 45 | integer, intent(in) :: ntau 46 | integer :: i,j,k 47 | ! integrate from bottom to surface to see error in w 48 | k=1 49 | do j=js_pe-onx+1,je_pe+onx 50 | do i=is_pe-onx+1,ie_pe+onx 51 | w(i,j,k,ntau) =-maskW(i,j,k)*dzt(k)* & 52 | (( u(i,j,k,ntau)- u(i-1,j,k,ntau))/(cost(j)*dxt(i)) & 53 | +(cosu(j)*v(i,j,k,ntau)-cosu(j-1)*v(i,j-1,k,ntau))/(cost(j)*dyt(j)) ) 54 | enddo 55 | enddo 56 | do k=2,nz 57 | do j=js_pe-onx+1,je_pe+onx 58 | do i=is_pe-onx+1,ie_pe+onx 59 | w(i,j,k,ntau) = w(i,j,k-1,ntau)-maskW(i,j,k)*dzt(k)* & 60 | (( u(i,j,k,ntau) -u(i-1,j,k,ntau))/(cost(j)*dxt(i)) & 61 | +(cosu(j)*v(i,j,k,ntau)-cosu(j-1)*v(i,j-1,k,ntau))/(cost(j)*dyt(j)) ) 62 | enddo 63 | enddo 64 | enddo 65 | end subroutine vertical_velocity_tau 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /for_src/non_hydrostatic/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: non_hydrostatic.o 5 | 6 | clean : 7 | rm -f *.o *.mod 8 | 9 | non_hydrostatic.o: non_hydrostatic.f90 ../main/main_module.o 10 | $(F90) $(F90FLAGS) -I../main -c non_hydrostatic.f90 11 | 12 | -------------------------------------------------------------------------------- /for_src/obc/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: obc_module.o obc.o 5 | 6 | obc_module.o: obc_module.f90 ../main/main_module.o 7 | $(F90) $(F90FLAGS) -I../main -c obc_module.f90 8 | obc.o: obc.f90 ../main/main_module.o obc_module.o 9 | $(F90) $(F90FLAGS) -I../main -c obc.f90 10 | clean : 11 | rm -f *.o *.mod 12 | 13 | -------------------------------------------------------------------------------- /for_src/obc/obc_module.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | module obc_module 5 | implicit none 6 | logical :: enable_obc_north = .false. 7 | logical :: enable_obc_south = .false. 8 | logical :: enable_prescribe_psi_obc_south = .false. 9 | logical :: enable_prescribe_psi_obc_north = .false. 10 | logical :: enable_restore_TS_obc_south = .false. 11 | logical :: enable_restore_TS_obc_north = .false. 12 | real*8, allocatable :: psi_wall_north(:),psi_wall_south(:) 13 | real*8, allocatable :: temp_wall_north(:,:),temp_wall_south(:,:) 14 | real*8, allocatable :: salt_wall_north(:,:),salt_wall_south(:,:) 15 | real*8 :: obc_tscl = 0.0 16 | real*8 :: obc_K_h = 0.0 17 | logical :: enable_obc_north_damping = .false. 18 | logical :: enable_obc_south_damping = .false. 19 | real*8 :: obc_north_damping_len = 1. 20 | real*8 :: obc_south_damping_len = 1. 21 | real*8 :: obc_north_damping_amp = 0. 22 | real*8 :: obc_south_damping_amp = 0. 23 | end module obc_module 24 | 25 | subroutine allocate_obc_module 26 | use main_module 27 | use obc_module 28 | if (enable_obc_north) then 29 | allocate(psi_wall_north(is_pe-onx:ie_pe+onx) ); psi_wall_north=0.0 30 | allocate(temp_wall_north(is_pe-onx:ie_pe+onx,nz) ); temp_wall_north=0.0 31 | allocate(salt_wall_north(is_pe-onx:ie_pe+onx,nz) ); salt_wall_north=0.0 32 | endif 33 | if (enable_obc_south) then 34 | allocate(psi_wall_south(is_pe-onx:ie_pe+onx) ); psi_wall_south=0.0 35 | allocate(temp_wall_south(is_pe-onx:ie_pe+onx,nz) ); temp_wall_south=0.0 36 | allocate(salt_wall_south(is_pe-onx:ie_pe+onx,nz) ); salt_wall_south=0.0 37 | endif 38 | end subroutine allocate_obc_module 39 | -------------------------------------------------------------------------------- /for_src/parallel/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | parallel_none.o: parallel_none.f90 ../main/main_module.o 5 | $(F90) $(F90FLAGS) -I../main -c parallel_none.f90 6 | parallel_mpi.o: parallel_mpi.f90 ../main/main_module.o 7 | $(F90) $(F90FLAGS) $(MPIFLAGS) -I../main -c parallel_mpi.f90 8 | clean : 9 | rm -f *.o *.mod 10 | 11 | -------------------------------------------------------------------------------- /for_src/rossmix/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: rossmix_module.o rossmix.o rossmix_integrate.o rossmix_reflect.o rossmix_group_velocity.o \ 5 | rossmix_flux.o rossmix_friction.o 6 | 7 | clean : 8 | rm -f *.o *.mod 9 | 10 | rossmix_module.o : rossmix_module.f90 ../main/main_module.o 11 | $(F90) $(F90FLAGS) -I../main -c rossmix_module.f90 12 | rossmix.o: rossmix.f90 ../main/main_module.o ../etc/timing_module.o rossmix_module.o 13 | $(F90) $(F90FLAGS) -I../main -I../etc -c rossmix.f90 14 | rossmix_flux.o: rossmix_flux.f90 ../main/main_module.o rossmix_module.o 15 | $(F90) $(F90FLAGS) -I../main -c rossmix_flux.f90 16 | rossmix_integrate.o: rossmix_integrate.f90 ../main/main_module.o ../etc/timing_module.o rossmix_module.o 17 | $(F90) $(F90FLAGS) -I../main -I../etc -c rossmix_integrate.f90 18 | rossmix_friction.o: rossmix_friction.f90 ../main/main_module.o rossmix_module.o 19 | $(F90) $(F90FLAGS) -I../main -c rossmix_friction.f90 20 | rossmix_reflect.o: rossmix_reflect.f90 ../main/main_module.o rossmix_module.o 21 | $(F90) $(F90FLAGS) -I../main -c rossmix_reflect.f90 22 | rossmix_group_velocity.o: rossmix_group_velocity.f90 ../main/main_module.o rossmix_module.o 23 | $(F90) $(F90FLAGS) -I../main -c rossmix_group_velocity.f90 24 | -------------------------------------------------------------------------------- /for_src/rossmix2/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | include ../../site_specific.mk_${HOSTTYPE} 4 | 5 | all: rossmix2_module.o rossmix2.o rossmix2_parameter.o rossmix2_diag_snap.o rossmix2_friction.o 6 | 7 | clean : 8 | rm -f *.o *.mod 9 | 10 | rossmix2_module.o : rossmix2_module.f90 ../main/main_module.o 11 | $(F90) $(F90FLAGS) -I../main -c rossmix2_module.f90 12 | rossmix2.o: rossmix2.f90 ../main/main_module.o ../etc/timing_module.o rossmix2_module.o 13 | $(F90) $(F90FLAGS) -I../main -I../etc -I../diagnostics -c rossmix2.f90 14 | rossmix2_parameter.o: rossmix2_parameter.f90 ../main/main_module.o ../etc/timing_module.o rossmix2_module.o 15 | $(F90) $(F90FLAGS) -I../main -I../etc -c rossmix2_parameter.f90 16 | rossmix2_friction.o: rossmix2_friction.f90 ../main/main_module.o ../etc/timing_module.o rossmix2_module.o 17 | $(F90) $(F90FLAGS) -I../main -I../etc -c rossmix2_friction.f90 18 | rossmix2_diag_snap.o: rossmix2_diag_snap.f90 ../main/main_module.o ../etc/timing_module.o rossmix2_module.o 19 | $(F90) $(F90FLAGS) $(CDFFLAGS) -I../main -I../etc -c rossmix2_diag_snap.f90 20 | -------------------------------------------------------------------------------- /for_src/tke/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: tke_module.o tke.o 5 | 6 | tke_module.o: tke_module.f90 ../main/main_module.o 7 | $(F90) $(F90FLAGS) -I../main -c tke_module.f90 8 | tke.o: tke.f90 ../main/main_module.o tke_module.o \ 9 | ../eke/eke_module.o ../idemix/idemix_module.o 10 | $(F90) $(F90FLAGS) -I../main -I../idemix -I../eke -c tke.f90 11 | clean : 12 | rm -f *.o *.mod 13 | 14 | -------------------------------------------------------------------------------- /for_src/tke/tke_module.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | module tke_module 6 | implicit none 7 | !--------------------------------------------------------------------------------- 8 | ! TKE model 9 | !--------------------------------------------------------------------------------- 10 | logical :: enable_tke = .false. 11 | real*8, allocatable :: dtke(:,:,:,:) ! tendency due to advection using Adam Bashforth 12 | real*8, allocatable :: tke(:,:,:,:) ! small-scale tke 13 | real*8, allocatable :: mxl(:,:,:) ! eddy length scale 14 | real*8, allocatable :: sqrttke(:,:,:) ! square root of TKE 15 | real*8, allocatable :: Prandtlnumber(:,:,:) 16 | real*8, allocatable :: forc_tke_surface(:,:) 17 | real*8, allocatable :: tke_surf_corr(:,:) 18 | real*8, allocatable :: tke_diss(:,:,:) 19 | real*8 :: c_k = 0.1 20 | real*8 :: c_eps = 0.7 21 | real*8 :: alpha_tke = 1.0 22 | real*8 :: mxl_min = 1d-12 23 | real*8 :: kappaM_min = 0.d0 24 | real*8 :: kappaM_max = 100.d0 25 | integer :: tke_mxl_choice = 1 26 | 27 | logical :: enable_tke_superbee_advection = .false. 28 | logical :: enable_tke_dst3_advection = .false. 29 | logical :: enable_tke_AB_time_stepping = .true. 30 | logical :: enable_tke_hor_diffusion = .false. 31 | real*8 :: K_h_tke = 2000.0 ! lateral diffusivity for tke 32 | end module tke_module 33 | 34 | 35 | subroutine allocate_tke_module 36 | use main_module 37 | use tke_module 38 | 39 | if (enable_tke) then 40 | allocate(dtke(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,3) );dtke = 0.0 41 | allocate( tke(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,3) ); tke = 0.0 42 | allocate( mxl(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); mxl = 0 43 | allocate( sqrttke(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); sqrttke = 0 44 | allocate( Prandtlnumber(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); Prandtlnumber = 0 45 | allocate( forc_tke_surface(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); forc_tke_surface = 0 46 | allocate( tke_diss(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz) ); tke_diss = 0.0 47 | allocate( tke_surf_corr(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx) ); tke_surf_corr = 0 48 | endif 49 | 50 | end subroutine allocate_tke_module 51 | -------------------------------------------------------------------------------- /for_src/tools/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | 5 | convert_restart.o: convert_restart.f90 6 | $(F90) $(F90FLAGS) convert_restart.f90 -o convert_restart.x 7 | 8 | clean : 9 | rm -f *.o *.mod 10 | 11 | -------------------------------------------------------------------------------- /for_src/tracer/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../site_specific.mk_${HOSTTYPE} 3 | 4 | all: tracer_module.o tracer.o 5 | 6 | tracer_module.o: tracer_module.f90 ../main/main_module.o 7 | $(F90) $(F90FLAGS) -I../main -c tracer_module.f90 8 | tracer.o: tracer.f90 ../main/main_module.o ../etc/timing_module.o \ 9 | ../isoneutral/isoneutral_module.o ../rossmix/rossmix_module.o tracer_module.o 10 | $(F90) $(F90FLAGS) -I../main -I../isoneutral -I../rossmix -I../etc -c tracer.f90 11 | clean : 12 | rm -f *.o *.mod 13 | 14 | -------------------------------------------------------------------------------- /for_src/tracer/tracer_module.f90: -------------------------------------------------------------------------------- 1 | 2 | 3 | module tracer_module 4 | implicit none 5 | !--------------------------------------------------------------------------------- 6 | !--------------------------------------------------------------------------------- 7 | logical :: enable_tracer = .false. 8 | integer :: n_trac = 0 9 | real*8, allocatable :: dtrac(:,:,:,:,:) ! tendency due to advection using Adam Bashforth 10 | real*8, allocatable :: trac(:,:,:,:,:) ! tracer 11 | real*8, allocatable :: trac_source(:,:,:,:) ! tracer source 12 | real*8, allocatable :: forc_trac_surface(:,:,:) ! tracer 13 | end module tracer_module 14 | 15 | subroutine allocate_tracer_module 16 | use main_module 17 | use tracer_module 18 | if (enable_tracer) then 19 | if (n_trac <= 0 ) then 20 | if (my_pe==0) print*,' ERROR: n_trac <=0 in allocate_tracer_module, set n_trac to positive number larger zero' 21 | call halt_stop('in allocate_tracer_module') 22 | endif 23 | allocate(dtrac(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,3,n_trac) );dtrac = 0.0 24 | allocate( trac(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,3,n_trac) ); trac = 0.0 25 | allocate( forc_trac_surface(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,n_trac) ); forc_trac_surface = 0.0 26 | allocate( trac_source(is_pe-onx:ie_pe+onx,js_pe-onx:je_pe+onx,nz,n_trac) ); trac_source = 0.0 27 | endif 28 | end subroutine allocate_tracer_module 29 | 30 | 31 | -------------------------------------------------------------------------------- /py_config/Makefile: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /py_config/enso1.py: -------------------------------------------------------------------------------- 1 | 2 | import sys; sys.path.append('../py_src') 3 | from pyOM_gui import pyOM_gui as pyOM 4 | from numpy import * 5 | 6 | BETA=2e-11 7 | 8 | class enso1(pyOM): 9 | """ Enso response 10 | """ 11 | def set_parameter(self): 12 | """set main parameter 13 | """ 14 | M=self.fortran.main_module 15 | M.nx = 64*2 16 | M.nz = 1 17 | M.ny = 64*2 18 | M.dt_mom = 3600.0 /2. 19 | M.dt_tracer = 3600.0 /2. 20 | 21 | M.congr_epsilon = 1e-12 22 | M.enable_streamfunction = 0 23 | M.enable_free_surface = 1 24 | M.eq_of_state_type = 1 25 | 26 | M.enable_conserve_energy = 0 27 | M.coord_degree = 0 28 | 29 | M.enable_biharmonic_friction = 1 30 | M.a_hbi = .05e11 31 | 32 | M.enable_hydrostatic = 1 33 | M.enable_cyclic_x = 0 34 | M.enable_superbee_advection = 1 35 | #M.enable_quicker_mom_advection= 0 36 | #M.enable_no_mom_advection = 1 37 | 38 | M.enable_momentum_sources = 1 39 | return 40 | 41 | def set_grid(self): 42 | M=self.fortran.main_module 43 | M.dxt[:] = 50e3 44 | M.dyt[:] = 50e3 45 | M.dzt[:] = (500e3**2*BETA) **2 /9.81 46 | return 47 | 48 | 49 | def set_coriolis(self): 50 | """ vertical and horizontal Coriolis parameter on yt grid 51 | routine is called after initialization of grid 52 | """ 53 | M=self.fortran.main_module 54 | y0=M.ny*M.dxt[0]*0.5 55 | for j in range( M.yt.shape[0] ): M.coriolis_t[:,j] = BETA*(M.yt[j]-y0) 56 | return 57 | 58 | def set_forcing(self): 59 | M=self.fortran.main_module 60 | t = M.dt_tracer*M.itt 61 | if t/86400.>3.0: M.surface_taux[:] = 0. 62 | 63 | y1=10*M.dyt[0] 64 | y2=(M.ny-10)*M.dyt[0] 65 | dy = 2*y1 66 | lam = 1/(3600.*10) 67 | for j in range(M.js_pe,M.je_pe+1): 68 | #print j,M.yt[j],y1,exp( -(M.yt[j]-y1)**2/dy**2) 69 | M.u_source[:,j,:]= -lam*M.u[:,j,:,M.tau-1]*(exp(-(M.yt[j]-y1)**2/dy**2) + 70 | exp(-(M.yt[j]-y2)**2/dy**2) ) 71 | M.v_source[:,j,:]= -lam*M.v[:,j,:,M.tau-1]*(exp(-(M.yt[j]-y1)**2/dy**2) + 72 | exp(-(M.yt[j]-y2)**2/dy**2) ) 73 | #stop 74 | return 75 | 76 | def set_initial_conditions(self): 77 | """ setup all initial conditions 78 | """ 79 | M=self.fortran.main_module 80 | M.u[:]=0. 81 | M.v[:]=0. 82 | M.w[:]=0. 83 | M.psi[:] = 0. 84 | M.itt = 0 85 | cn = (M.dzt[0]*9.81)**0.5 86 | hn=cn**2/9.81 87 | Re = (cn /BETA)**0.5 88 | y0=M.ny*M.dxt[0]*0.5 89 | g=9.81 90 | print("Eq. Rossby radius = ",Re/1e3," km") 91 | print("c_n = ",cn," m/s") 92 | print("h_n = ",hn," m" ) 93 | 94 | #for i in range(M.xt.shape[0]): 95 | # for j in range(M.yt.shape[0]): 96 | # M.psi[i,j,:]=0.1*exp( -(M.xt[i]-y0*0.5)**2/(0.5*Re)**2 -(M.yt[j]-y0)**2/(0.5*Re)**2 ) 97 | 98 | # wind stress forcing 99 | x0 = 1.5e6 100 | for i in range(M.is_pe,M.ie_pe+1): 101 | ii = self.if2py(i) 102 | taux=0.0 103 | #if M.xt[ii]>1e6 and M.xt[ii]<2e6: 104 | M.surface_taux[ii,:] = .1e-3*exp( -(M.yt-y0)**2/(3*Re)**2 )*exp(-(M.xt[ii]-x0)**2/0.5e6**2 ) 105 | 106 | return 107 | 108 | def make_plot(self): 109 | """ make a plot using methods of self.figure 110 | """ 111 | if hasattr(self,'figure'): 112 | M=self.fortran.main_module # fortran module with model variables 113 | x=M.xt[2:-2]/1e3 114 | y=(M.yt[2:-2]-M.ny/2*M.dyt[0])/1e3 115 | 116 | self.figure.clf() 117 | ax=self.figure.add_subplot(111) 118 | a=M.psi[2:-2,2:-2,M.tau-1] 119 | co=ax.contourf(x,y,minimum(10,a.transpose()),arange(-10,12,1),cmap='jet') 120 | 121 | a=M.u[2:-2:4,2:-2:4,0,M.tau-1] 122 | b=M.v[2:-2:4,2:-2:4,0,M.tau-1] 123 | ax.quiver(x[::4],y[::4],a.transpose(),b.transpose(),angles='xy', scale_units='xy', scale=2e-3 ) 124 | 125 | t = M.dt_tracer*M.itt 126 | if t/86400.<3.0: 127 | ax.contour(x,y,M.surface_taux[2:-2,2:-2].transpose(),colors='k') 128 | 129 | self.figure.colorbar(co) 130 | ax.set_title('thermocline depth at t='+str(M.dt_tracer*M.itt /86400.)+" days") 131 | ax.set_xlabel('x [km]') 132 | ax.set_ylabel('y [km]') 133 | return 134 | 135 | if __name__ == "__main__": 136 | model= enso1() 137 | model.run(snapint=0.5*86400.0,runlen=365*86400.) 138 | 139 | -------------------------------------------------------------------------------- /py_config/internal_wave1.py: -------------------------------------------------------------------------------- 1 | 2 | import sys; sys.path.append('../py_src') 3 | from pyOM_gui import pyOM_gui as pyOM 4 | from numpy import * 5 | 6 | fac=1 7 | N_0 = 2*pi/10. 8 | OM0 = 1./(1.5*10) 9 | 10 | class internal_wave1(pyOM): 11 | 12 | """ internal wave maker 13 | """ 14 | 15 | def set_parameter(self): 16 | """set main parameter 17 | """ 18 | M=self.fortran.main_module 19 | (M.nx,M.ny,M.nz) = (64*fac,1,64*fac) 20 | 21 | M.dt_mom =20*0.025/fac 22 | M.dt_tracer=20*0.025/fac 23 | 24 | M.enable_conserve_energy = 0 25 | M.coord_degree = 0 26 | M.enable_cyclic_x = 1 27 | M.enable_hydrostatic = 0 28 | M.eq_of_state_type = 1 29 | 30 | M.congr_epsilon = 1e-12 31 | M.congr_max_iterations = 5000 32 | M.congr_epsilon_non_hydro= 1e-9 33 | M.congr_max_itts_non_hydro = 5000 34 | 35 | M.enable_explicit_vert_friction = 1 36 | M.kappam_0 = 5e-3/fac**2 37 | M.enable_hor_friction = 1 38 | M.a_h = 5e-3/fac**2 39 | M.enable_superbee_advection = 1 40 | 41 | M.enable_tempsalt_sources = 1 42 | M.enable_momentum_sources = 1 43 | return 44 | 45 | def set_grid(self): 46 | M=self.fortran.main_module 47 | M.dxt[:]= 0.25/fac 48 | M.dyt[:]= 0.25/fac 49 | M.dzt[:]= 0.25/fac 50 | return 51 | 52 | def set_topography(self): 53 | M=self.fortran.main_module 54 | M.kbot[:]=0 55 | M.kbot[:,2:-2]=1 56 | return 57 | 58 | 59 | def set_initial_conditions(self): 60 | """ setup all initial conditions 61 | """ 62 | M=self.fortran.main_module 63 | alpha = self.fortran.linear_eq_of_state.linear_eq_of_state_drhodt() 64 | grav = 9.81; rho0 = 1024.0 65 | 66 | self.t0 = zeros( (M.i_blk+2*M.onx,M.j_blk+2*M.onx,M.nz) , 'd', order='F') 67 | self.dt0 = zeros( (M.i_blk+2*M.onx,M.j_blk+2*M.onx,M.nz,3) , 'd', order='F') 68 | self.u0 = zeros( (M.i_blk+2*M.onx,M.j_blk+2*M.onx,M.nz) , 'd', order='F') 69 | 70 | # prescribed background stratification 71 | for k in range(M.nz): 72 | self.t0[:,:,k]=-N_0**2*M.zt[k]/grav/alpha*rho0*M.maskt[:,:,k] 73 | 74 | # wave maker 75 | for k in range(M.nz): 76 | self.u0[:,:,k]= M.masku[:,:,k]*1./(100*60.*M.dt_tracer)*exp( -(M.zt[k]-M.zt[M.nz//2-1])**2/(M.dzt[0]*1)**2 ) 77 | # find x for nx/2 78 | x0 = zeros( (1,) , 'd', order='F') 79 | if M.nx//2 >= M.is_pe and M.nx//2<= M.ie_pe: 80 | x0 = M.xu[self.if2py(M.nx//2)] 81 | self.fortran.global_max(x0) 82 | for i in range( self.u0.shape[0]): 83 | self.u0[i,:,:]= self.u0[i,:,:]*exp( -(M.xu[i]-x0)**2/(M.dxu[0]*1)**2 ) 84 | return 85 | 86 | def set_forcing(self): 87 | M=self.fortran.main_module 88 | # implement effect of background state 89 | # update density, etc of last time step 90 | M.temp[:,:,:,M.tau-1] = M.temp[:,:,:,M.tau-1] + self.t0 91 | self.fortran.calc_eq_of_state(M.tau) 92 | M.temp[:,:,:,M.tau-1] = M.temp[:,:,:,M.tau-1] - self.t0 93 | 94 | # advection of background temperature 95 | self.fortran.advect_tracer(M.is_pe-M.onx,M.ie_pe+M.onx,M.js_pe-M.onx,M.je_pe+M.onx,self.t0,self.dt0[...,M.tau-1],M.nz) 96 | M.temp_source[:] = (1.5+M.ab_eps)*self.dt0[...,M.tau-1] - ( 0.5+M.ab_eps)*self.dt0[...,M.taum1-1] 97 | 98 | # wave maker 99 | M.u_source[:,:,:]= self.u0[:,:,:]*sin(2*pi*OM0*M.itt*M.dt_tracer) 100 | return 101 | 102 | def user_defined_signal(self): 103 | """ this routine must be called by all processors 104 | """ 105 | M=self.fortran.main_module 106 | a = zeros( (M.nx,M.ny), 'd', order = 'F') 107 | a[M.is_pe-1:M.ie_pe,0] = M.xt[2:-2] 108 | self.fortran.pe0_recv_2d(a) 109 | self.xt_gl = a[:,0].copy() 110 | 111 | self.temp_gl = zeros( (M.nx,M.ny,M.nz), 'd', order = 'F') 112 | self.t0_gl = zeros( (M.nx,M.ny,M.nz), 'd', order = 'F') 113 | self.u_gl = zeros( (M.nx,M.ny,M.nz), 'd', order = 'F') 114 | self.w_gl = zeros( (M.nx,M.ny,M.nz), 'd', order = 'F') 115 | for k in range(M.nz): 116 | a[M.is_pe-1:M.ie_pe,M.js_pe-1:M.je_pe] = where( M.maskt[2:-2,2:-2,k] >0, M.temp[2:-2,2:-2,k,M.tau-1] , NaN) 117 | self.fortran.pe0_recv_2d(a) 118 | self.temp_gl[:,:,k]=a.copy() 119 | 120 | a[M.is_pe-1:M.ie_pe,M.js_pe-1:M.je_pe] = where( M.maskt[2:-2,2:-2,k] >0, self.t0[2:-2,2:-2,k] , NaN) 121 | self.fortran.pe0_recv_2d(a) 122 | self.t0_gl[:,:,k]=a.copy() 123 | 124 | a[M.is_pe-1:M.ie_pe,M.js_pe-1:M.je_pe] = where( M.masku[2:-2,2:-2,k] >0, M.u[2:-2,2:-2,k,M.tau-1] , NaN) 125 | self.fortran.pe0_recv_2d(a) 126 | self.u_gl[:,:,k]=a.copy() 127 | 128 | a[M.is_pe-1:M.ie_pe,M.js_pe-1:M.je_pe] = where( M.maskw[2:-2,2:-2,k] >0, M.w[2:-2,2:-2,k,M.tau-1] , NaN) 129 | self.fortran.pe0_recv_2d(a) 130 | self.w_gl[:,:,k]=a.copy() 131 | 132 | 133 | def make_plot(self): 134 | M=self.fortran.main_module 135 | 136 | self.set_signal('user_defined') # following routine is called by all PEs 137 | self.user_defined_signal() 138 | 139 | self.figure.clf() 140 | ax=self.figure.add_subplot(111) 141 | t = self.temp_gl[:,0,:] 142 | u = self.u_gl[:,0,:] 143 | w = self.w_gl[:,0,:] 144 | t[M.nx//2-3*fac:M.nx//2+2*fac,M.nz//2-3*fac:M.nz//2+2*fac]=0 145 | u[M.nx//2-3*fac:M.nx//2+2*fac,M.nz//2-3*fac:M.nz//2+2*fac]=0 146 | w[M.nx//2-3*fac:M.nx//2+2*fac,M.nz//2-3*fac:M.nz//2+2*fac]=0 147 | co=ax.contourf(self.xt_gl,M.zt,t.transpose() ) 148 | self.figure.colorbar(co) 149 | ax.contour(self.xt_gl,M.zt,(t+self.t0_gl[:,0,:]).transpose(),10,colors='red') 150 | ax.quiver(self.xt_gl[::2*fac],M.zt[::2*fac],u[::2*fac,::2*fac].transpose(),w[::2*fac,::2*fac].transpose() ) 151 | 152 | ax.set_title('Temperature') 153 | ax.set_xlabel('x [m]') 154 | ax.set_ylabel('z [m]') 155 | ax.axis('tight') 156 | return 157 | 158 | if __name__ == "__main__": 159 | internal_wave1().run(snapint = 0.5 ,runlen = 50.0) 160 | 161 | -------------------------------------------------------------------------------- /py_config/kelv_helm1.py: -------------------------------------------------------------------------------- 1 | 2 | import sys; sys.path.append('../py_src') 3 | 4 | 5 | from pyOM_gui import pyOM_gui as pyOM 6 | #from pyOM_cdf import pyOM_cdf as pyOM 7 | from numpy import * 8 | 9 | fac = 1.0 10 | mix = 2.5e-3 11 | 12 | 13 | class kelv1(pyOM): 14 | """ 15 | """ 16 | def set_parameter(self): 17 | """set main parameter 18 | """ 19 | M=self.fortran.main_module 20 | 21 | (M.nx,M.ny,M.nz)=(int(1.5*64*fac), 1, int(40*fac) ) 22 | M.dt_mom = 0.04/fac 23 | M.dt_tracer = 0.04/fac 24 | 25 | M.enable_conserve_energy = 0 26 | M.coord_degree = 0 27 | M.enable_cyclic_x = 1 28 | M.enable_hydrostatic = 0 29 | M.eq_of_state_type = 1 30 | 31 | M.congr_epsilon = 1e-12 32 | M.congr_max_iterations = 5000 33 | M.congr_epsilon_non_hydro= 1e-6 34 | M.congr_max_itts_non_hydro = 5000 35 | 36 | M.enable_explicit_vert_friction = 1 37 | M.kappam_0 = mix/fac**2 38 | M.enable_hor_friction = 1 39 | M.a_h = mix/fac**2 40 | 41 | M.enable_tempsalt_sources = 0 42 | M.enable_momentum_sources = 0 43 | M.enable_superbee_advection = 1 44 | return 45 | 46 | 47 | def set_grid(self): 48 | M=self.fortran.main_module 49 | M.dxt[:]=0.25/fac 50 | M.dyt[:]=0.25/fac 51 | M.dzt[:]=0.25/fac 52 | return 53 | 54 | def t_star_fct(self,k): 55 | M=self.fortran.main_module 56 | return 9.85-6.5*tanh( (M.zt[k-1]-M.zt[M.nz//2-1] ) /M.zt[0]*100 ) 57 | 58 | def u_star_fct(self,k): 59 | M=self.fortran.main_module 60 | return 0.6+0.5*tanh( (M.zt[k-1]-M.zt[M.nz//2-1])/M.zt[0]*100) 61 | 62 | 63 | def set_initial_conditions(self): 64 | """ setup initial conditions 65 | """ 66 | M=self.fortran.main_module 67 | 68 | # target for restoring 69 | self.t_rest = zeros( M.u[:,:,:,0].shape, order = 'F' ) 70 | self.t_star = zeros( M.u[:,:,:,0].shape, order = 'F' ) 71 | self.u_star = zeros( M.u[:,:,:,0].shape, order = 'F' ) 72 | 73 | for k in range(M.nz): 74 | self.t_star[:,:,k]=self.t_star_fct(k+1) 75 | self.u_star[:,:,k]=self.u_star_fct(k+1) 76 | for i in range(M.is_pe,M.ie_pe+1): 77 | if i < M.nx/8: self.t_rest[self.if2py(i),:,k] = 1./(15*M.dt_mom) 78 | 79 | # initial conditions 80 | from numpy.random import randn 81 | for k in range(M.nz): 82 | M.u[:,:,k,:] = self.u_star_fct(k+1) 83 | for i in range(M.is_pe,M.ie_pe+1): 84 | ii = self.if2py(i) 85 | fxa=1e-2*M.zt[0]*sin(M.xt[ii]/(M.nx*M.dxt[1])*4*pi)*sin(M.zt[k]/( M.zt[0]-M.dzt[0]/2)*pi) 86 | M.temp[ii,:,k,:]= fxa+self.t_star_fct(k+1) 87 | return 88 | 89 | 90 | def set_forcing(self): 91 | M=self.fortran.main_module 92 | if M.enable_tempsalt_sources: M.temp_source[:]=self.t_rest*(self.t_star-M.temp[:,:,:,M.tau-1])#*M.maskt[:] 93 | if M.enable_momentum_sources: M.u_source[:] =self.t_rest*(self.u_star-M.u[:,:,:,M.tau-1] )#*M.masku[:] 94 | return 95 | 96 | 97 | def user_defined_signal(self): 98 | """ this routine must be called by all processors 99 | """ 100 | M=self.fortran.main_module 101 | a = zeros( (M.nx,M.ny), 'd', order = 'F') 102 | a[M.is_pe-1:M.ie_pe,0] = M.xt[2:-2] 103 | self.fortran.pe0_recv_2d(a) 104 | self.xt_gl = a[:,0].copy() 105 | 106 | self.temp_gl = zeros( (M.nx,M.ny,M.nz), 'd', order = 'F') 107 | self.u_gl = zeros( (M.nx,M.ny,M.nz), 'd', order = 'F') 108 | self.w_gl = zeros( (M.nx,M.ny,M.nz), 'd', order = 'F') 109 | for k in range(M.nz): 110 | a[M.is_pe-1:M.ie_pe,M.js_pe-1:M.je_pe] = where( M.maskt[2:-2,2:-2,k] >0, M.temp[2:-2,2:-2,k,M.tau-1] , NaN) 111 | self.fortran.pe0_recv_2d(a) 112 | self.temp_gl[:,:,k]=a.copy() 113 | 114 | a[M.is_pe-1:M.ie_pe,M.js_pe-1:M.je_pe] = where( M.masku[2:-2,2:-2,k] >0, M.u[2:-2,2:-2,k,M.tau-1] , NaN) 115 | self.fortran.pe0_recv_2d(a) 116 | self.u_gl[:,:,k]=a.copy() 117 | 118 | a[M.is_pe-1:M.ie_pe,M.js_pe-1:M.je_pe] = where( M.maskw[2:-2,2:-2,k] >0, M.w[2:-2,2:-2,k,M.tau-1] , NaN) 119 | self.fortran.pe0_recv_2d(a) 120 | self.w_gl[:,:,k]=a.copy() 121 | 122 | return 123 | 124 | def make_plot(self): 125 | M=self.fortran.main_module 126 | 127 | self.set_signal('user_defined') # following routine is called by all PEs 128 | self.user_defined_signal() 129 | 130 | self.figure.clf() 131 | ax=self.figure.add_subplot(211) 132 | 133 | co=ax.contourf(self.xt_gl,M.zt, self.temp_gl[:,0,:].transpose()) 134 | self.figure.colorbar(co) 135 | ax.quiver(self.xt_gl[::2],M.zt[::2],self.u_gl[::2,0,::2].transpose(),self.w_gl[::2,0,::2].transpose() ) 136 | ax.set_title('Temperature [deg C]') 137 | ax.set_xlabel('x [m]') 138 | ax.set_ylabel('z [m]') 139 | #ax.axis('tight') 140 | return 141 | 142 | 143 | if __name__ == "__main__": 144 | m=kelv1() 145 | dt=m.fortran.main_module.dt_tracer 146 | m.run( snapint = 2.0 ,runlen = 50.0) 147 | -------------------------------------------------------------------------------- /py_config/kelv_helm2.py: -------------------------------------------------------------------------------- 1 | 2 | import sys; sys.path.append('../py_src') 3 | 4 | 5 | from pyOM_gui import pyOM_gui as pyOM 6 | #from pyOM_cdf import pyOM_cdf as pyOM 7 | from numpy import * 8 | 9 | fac = 1.0 10 | mix = 2.5e-3 11 | 12 | 13 | class kelv1(pyOM): 14 | """ 15 | """ 16 | def set_parameter(self): 17 | """set main parameter 18 | """ 19 | M=self.fortran.main_module 20 | 21 | (M.nx,M.ny,M.nz)=(int(1.5*64*fac), 1, int(40*fac) ) 22 | M.dt_mom = 0.04/fac 23 | M.dt_tracer = 0.04/fac 24 | 25 | M.enable_conserve_energy = 0 26 | M.coord_degree = 0 27 | M.enable_cyclic_x = 1 28 | M.enable_hydrostatic = 0 29 | M.eq_of_state_type = 1 30 | 31 | M.congr_epsilon = 1e-12 32 | M.congr_max_iterations = 5000 33 | M.congr_epsilon_non_hydro= 1e-6 34 | M.congr_max_itts_non_hydro = 5000 35 | 36 | M.enable_explicit_vert_friction = 1 37 | M.kappam_0 = mix/fac**2 38 | M.enable_hor_friction = 1 39 | M.a_h = mix/fac**2 40 | 41 | M.enable_tempsalt_sources = 0 42 | M.enable_momentum_sources = 0 43 | M.enable_superbee_advection = 1 44 | return 45 | 46 | 47 | def set_grid(self): 48 | M=self.fortran.main_module 49 | M.dxt[:]=0.25/fac 50 | M.dyt[:]=0.25/fac 51 | M.dzt[:]=0.25/fac 52 | return 53 | 54 | 55 | def u_star_fct(self,k): 56 | M=self.fortran.main_module 57 | return 0.6+0.5*tanh( (M.zt[k-1]-M.zt[M.nz//2-1])/M.zt[0]*300) 58 | 59 | 60 | def set_initial_conditions(self): 61 | """ setup initial conditions 62 | """ 63 | M=self.fortran.main_module 64 | 65 | # target for restoring 66 | 67 | 68 | # initial conditions 69 | from numpy.random import randn 70 | for k in range(M.nz): 71 | M.u[:,:,k,:] = self.u_star_fct(k+1) 72 | for i in range(M.is_pe,M.ie_pe+1): 73 | ii = self.if2py(i) 74 | fxa=0.05*M.zt[0]*sin(M.xt[ii]/(M.nx*M.dxt[1])*4*pi)*sin(M.zt[k]/( M.zt[0]-M.dzt[0]/2)*pi) 75 | M.u[ii,:,k,:]= fxa+ M.u[ii,:,k,:] 76 | return 77 | 78 | 79 | 80 | 81 | def user_defined_signal(self): 82 | """ this routine must be called by all processors 83 | """ 84 | M=self.fortran.main_module 85 | a = zeros( (M.nx,M.ny), 'd', order = 'F') 86 | a[M.is_pe-1:M.ie_pe,0] = M.xt[2:-2] 87 | self.fortran.pe0_recv_2d(a) 88 | self.xt_gl = a[:,0].copy() 89 | 90 | self.temp_gl = zeros( (M.nx,M.ny,M.nz), 'd', order = 'F') 91 | self.u_gl = zeros( (M.nx,M.ny,M.nz), 'd', order = 'F') 92 | self.w_gl = zeros( (M.nx,M.ny,M.nz), 'd', order = 'F') 93 | for k in range(M.nz): 94 | a[M.is_pe-1:M.ie_pe,M.js_pe-1:M.je_pe] = where( M.maskt[2:-2,2:-2,k] >0, M.temp[2:-2,2:-2,k,M.tau-1] , NaN) 95 | self.fortran.pe0_recv_2d(a) 96 | self.temp_gl[:,:,k]=a.copy() 97 | 98 | a[M.is_pe-1:M.ie_pe,M.js_pe-1:M.je_pe] = where( M.masku[2:-2,2:-2,k] >0, M.u[2:-2,2:-2,k,M.tau-1] , NaN) 99 | self.fortran.pe0_recv_2d(a) 100 | self.u_gl[:,:,k]=a.copy() 101 | 102 | a[M.is_pe-1:M.ie_pe,M.js_pe-1:M.je_pe] = where( M.maskw[2:-2,2:-2,k] >0, M.w[2:-2,2:-2,k,M.tau-1] , NaN) 103 | self.fortran.pe0_recv_2d(a) 104 | self.w_gl[:,:,k]=a.copy() 105 | 106 | return 107 | 108 | def make_plot(self): 109 | M=self.fortran.main_module 110 | 111 | self.set_signal('user_defined') # following routine is called by all PEs 112 | self.user_defined_signal() 113 | 114 | self.figure.clf() 115 | ax=self.figure.add_subplot(211) 116 | 117 | co=ax.contourf(self.xt_gl,M.zt, self.temp_gl[:,0,:].transpose()) 118 | self.figure.colorbar(co) 119 | ax.quiver(self.xt_gl[::2],M.zt[::2],self.u_gl[::2,0,::2].transpose(),self.w_gl[::2,0,::2].transpose() ) 120 | ax.set_title('Temperature [deg C]') 121 | ax.set_xlabel('x [m]') 122 | ax.set_ylabel('z [m]') 123 | #ax.axis('tight') 124 | return 125 | 126 | 127 | if __name__ == "__main__": 128 | m=kelv1() 129 | dt=m.fortran.main_module.dt_tracer 130 | m.run( snapint = 2.0 ,runlen = 50.0) 131 | -------------------------------------------------------------------------------- /py_config/rayleigh.py: -------------------------------------------------------------------------------- 1 | 2 | import sys; sys.path.append('../py_src') 3 | from numpy import * 4 | from pyOM_gui import pyOM_gui as pyOM 5 | 6 | fac = 1.0 7 | mix = 2.5e-3 8 | 9 | class rayleigh(pyOM): 10 | 11 | def set_parameter(self): 12 | """set main parameter 13 | """ 14 | M=self.fortran.main_module 15 | M.nx=int(2*32*fac) 16 | M.nz=int(20*fac) 17 | M.ny=1 18 | M.dt_tracer=0.25/fac 19 | M.dt_mom =0.25/fac 20 | 21 | M.enable_conserve_energy = 0 22 | M.coord_degree = 0 23 | M.enable_cyclic_x = 1 24 | M.enable_hydrostatic = 0 25 | 26 | M.eq_of_state_type = 1 27 | M.enable_tempsalt_sources = 1 28 | 29 | M.congr_epsilon = 1e-6 30 | M.congr_max_iterations = 5000 31 | M.congr_epsilon_non_hydro= 1e-6 32 | M.congr_max_itts_non_hydro = 5000 33 | 34 | M.enable_explicit_vert_friction = 1 35 | M.kappam_0 = mix/fac**2 36 | M.enable_hor_friction = 1 37 | M.a_h = mix/fac**2 38 | 39 | M.enable_superbee_advection = 1 40 | #M.kappah_0 = mix/fac**2 41 | #M.enable_hor_diffusion = 1 42 | #M.k_h = mix/fac**2 43 | 44 | M.runlen = 86400.0 45 | return 46 | 47 | 48 | def set_grid(self): 49 | M=self.fortran.main_module 50 | M.dxt[:]=0.5/fac 51 | M.dyt[:]=0.5/fac 52 | M.dzt[:]=0.5/fac 53 | return 54 | 55 | def set_initial_conditions(self): 56 | """ setup all initial conditions 57 | """ 58 | M=self.fortran.main_module 59 | for i in range(M.is_pe,M.ie_pe+1): 60 | ii = self.if2py(i) 61 | M.temp[ii,:,:,:] = 0.05*sin(M.xt[ii]/(20*M.dxt[2])*pi) 62 | for k in [0,1,2]: M.temp[:,:,:,k] = M.temp[:,:,:,k]*M.maskt 63 | return 64 | 65 | def set_forcing(self): 66 | """ setup all forcing 67 | surface and bottom boundary conditions 68 | might be variable in time, called every time step 69 | """ 70 | M=self.fortran.main_module 71 | M.temp_source[:,:,-1] = -175/4185.5 /M.dzt[-1] 72 | M.temp_source[:,:,0 ] = 175/4185.5 /M.dzt[0] 73 | return 74 | 75 | 76 | def make_plot(self): 77 | """ diagnose the model variables, could be replaced by other version 78 | """ 79 | M=self.fortran.main_module # fortran module with model variables 80 | self.figure.clf() 81 | ax=self.figure.add_subplot(211) 82 | a=where( M.maskt[2:-2,2,:] >0, M.temp[2:-2,2,:,M.tau-1], NaN) 83 | co=ax.contourf(M.xt[2:-2],M.zt,a.transpose(),arange(-2.5,2.5,0.25)) 84 | self.figure.colorbar(co) 85 | ax.quiver(M.xt[2:-2:2],M.zt[::2],M.u[2:-2:2,2,::2,M.tau-1].transpose(),M.w[2:-2:2,2,::2,M.tau-1].transpose() ) 86 | ax.set_title('temperature') 87 | ax.set_xlabel('x [m]') 88 | ax.set_ylabel('z [m]') 89 | ax.axis('tight') 90 | return 91 | 92 | if __name__ == "__main__": rayleigh().run(5.0) 93 | 94 | -------------------------------------------------------------------------------- /py_config/rossby1.py: -------------------------------------------------------------------------------- 1 | 2 | import sys; sys.path.append('../py_src') 3 | from pyOM_gui import pyOM_gui as pyOM 4 | from numpy import * 5 | 6 | BETA = 2e-11 7 | F0 = 1e-4 8 | CN = 2.0 9 | RN = CN/F0 10 | 11 | class rossby1(pyOM): 12 | """ Rossby waves 13 | """ 14 | def set_parameter(self): 15 | """set main parameter 16 | """ 17 | M=self.fortran.main_module 18 | M.nx = 32 19 | M.ny = 32 20 | M.nz = 1 21 | M.dt_tracer = RN/CN*0.25 22 | M.dt_mom = RN/CN*0.25 23 | 24 | M.congr_epsilon = 1e-12 25 | M.enable_streamfunction = 0 26 | M.enable_free_surface = 1 27 | M.eq_of_state_type = 1 28 | 29 | M.enable_conserve_energy = 0 30 | M.coord_degree = 0 31 | 32 | M.enable_hydrostatic = 1 33 | M.enable_cyclic_x = 1 34 | M.enable_superbee_advection = 1 35 | #M.enable_quicker_mom_advection= 0 36 | #M.enable_no_mom_advection = 1 37 | #M.enable_biharmonic_friction = 1 38 | return 39 | 40 | def set_grid(self): 41 | M=self.fortran.main_module 42 | print ('Rossby radius is ',RN/1e3,' km') 43 | M.dxt[:] = RN/10.0 44 | M.dyt[:] = RN/10.0 45 | M.dzt[:] = CN**2/9.81 46 | #M.a_hbi = 1e11*(M.dxt[0]/50e3)**4 47 | return 48 | 49 | def set_coriolis(self): 50 | """ vertical and horizontal Coriolis parameter on yt grid 51 | routine is called after initialization of grid 52 | """ 53 | M=self.fortran.main_module 54 | for j in range( M.yt.shape[0] ): M.coriolis_t[:,j] = F0+BETA*M.yt[j] 55 | return 56 | 57 | def set_initial_conditions(self): 58 | """ setup all initial conditions 59 | """ 60 | M=self.fortran.main_module 61 | y0=M.ny*M.dxt[0]*0.5 62 | L = RN/5 63 | kx = 2*pi/(M.nx*M.dxt[0]) 64 | ky = pi/(M.ny*M.dyt[0]) 65 | for i in range(M.xt.shape[0]): 66 | for j in range(M.yt.shape[0]): 67 | #M.psi[i,j,:]=0.01*exp( -(M.xt[i]-y0)**2/L**2 -(M.yt[j]-y0)**2/L**2 ) 68 | M.psi[i,j,:]=0.01*cos( kx*M.xt[i] ) 69 | return 70 | 71 | def make_plot(self): 72 | """ make a plot using methods of self.figure 73 | """ 74 | if hasattr(self,'figure'): 75 | M=self.fortran.main_module # fortran module with model variables 76 | x=M.xt[2:-2]/1e3 77 | y=M.yt[2:-2]/1e3 78 | 79 | self.figure.clf() 80 | ax=self.figure.add_subplot(111) 81 | a=M.psi[2:-2,2:-2,M.tau-1] 82 | co=ax.contourf(x,y,a.transpose(),15) 83 | ax.set_xlabel('x [km]'); 84 | ax.set_ylabel('y [km]'); 85 | ax.set_title('$eta$ [m]'); 86 | 87 | 88 | if M.itt>0: 89 | a=M.u[2:-2:2,2:-2:2,0,M.tau-1] 90 | b=M.v[2:-2:2,2:-2:2,0,M.tau-1] 91 | ax.quiver(x[::2],y[::2],a.transpose(),b.transpose() ) 92 | self.figure.colorbar(co) 93 | return 94 | 95 | 96 | if __name__ == "__main__": 97 | model= rossby1() 98 | model.run(snapint=0.5*86400.0,runlen=365*86400.) 99 | -------------------------------------------------------------------------------- /py_config/test.py: -------------------------------------------------------------------------------- 1 | import Tkinter as tk 2 | import tkMessageBox 3 | 4 | class SampleApp(tk.Tk): 5 | def __init__(self, *args, **kwargs): 6 | tk.Tk.__init__(self, *args, **kwargs) 7 | self.button = tk.Button(self, text="Push me", command=self.OnButton) 8 | self.button.pack() 9 | 10 | def OnButton(self): 11 | result = tkMessageBox.askokcancel(title="File already exists", 12 | message="File already exists. Overwrite?") 13 | if result is True: 14 | print "User clicked Ok" 15 | else: 16 | print "User clicked Cancel" 17 | 18 | if __name__ == "__main__": 19 | app = SampleApp() 20 | app.mainloop() 21 | -------------------------------------------------------------------------------- /py_config/test1.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import numpy.fft 3 | import pylab as plt 4 | 5 | u_0 = 0.5 6 | z=np.linspace( -1000,0,1000) 7 | dz = z[1]-z[0] 8 | I=complex(0,1) 9 | print dz 10 | 11 | u=u_0*z 12 | m=2*np.pi*numpy.fft.fftfreq(u.shape[0],dz) 13 | U=numpy.fft.fft(u) 14 | uz= np.real( numpy.fft.ifft( I*m*U) ) 15 | 16 | fig=plt.figure(figsize=(12,8)) 17 | fig.clf() 18 | ax=fig.add_subplot(221) 19 | ax.plot(z,uz) 20 | ax=fig.add_subplot(222) 21 | ax.plot(m,np.log10( np.abs(U)**2) ) 22 | ax=fig.add_subplot(223) 23 | ax.plot(np.log10( np.abs(U)**2 )) 24 | 25 | plt.show() 26 | 27 | 28 | -------------------------------------------------------------------------------- /py_config/test_tke1.py: -------------------------------------------------------------------------------- 1 | 2 | # ############################################################## 3 | # 1D case for tke model 4 | # ############################################################## 5 | 6 | import sys; sys.path.append('../py_src') 7 | from pyOM_cdf import pyOM_cdf as pyOM 8 | import numpy as np 9 | 10 | N_0 = 0.02 11 | 12 | class test_tke1(pyOM): 13 | 14 | def set_parameter(self): 15 | 16 | M=self.fortran.main_module 17 | M.nx = 1 18 | M.ny = 1 19 | M.nz = 50 20 | M.snapint = 86400 /6 21 | M.dt_mom = 360 # time step in second for momentum 22 | M.dt_tracer = 360 # time step for tracer 23 | 24 | M.enable_momentum_equation = 0 25 | M.enable_thermodynamic_equation = 1 26 | M.enable_conserve_energy = 0 27 | M.coord_degree = 0 28 | M.enable_cyclic_x = 1 29 | M.enable_cyclic_y = 1 30 | M.eq_of_state_type = 5 # 1: linear, 3: non-linear, 5:TEOS ? 31 | M.enable_diag_snapshots = 1 32 | 33 | M.enable_implicit_vert_friction = 1 34 | T=self.fortran.tke_module 35 | T.enable_tke = 1 36 | T.alpha_tke = 30.0 37 | T.tke_mxl_choice = 2 38 | return 39 | 40 | def set_grid(self): 41 | 42 | M=self.fortran.main_module 43 | M.dxt[:] = 5e3 44 | M.dyt[:] = 5e3 45 | M.dzt[:] = 1.0 46 | return 47 | 48 | def set_coriolis(self): 49 | return 50 | 51 | def set_topography(self): 52 | M=self.fortran.main_module 53 | M.kbot[:]=0 54 | return 55 | 56 | def set_initial_conditions(self): 57 | 58 | M=self.fortran.main_module 59 | M.salt[:]= 35. 60 | 61 | for k in range(M.nz): 62 | alpha = self.fortran.gsw_eq_of_state.gsw_drhodt(35.,20.,0.) 63 | M.temp[:,:,k,:] = 32+M.rho_0/M.grav/alpha*(-N_0**2*M.zt[k]) 64 | 65 | T = self.fortran.tke_module 66 | T.tke[:] = 1e-12 67 | T.forc_tke_surface[:] = np.sqrt( (0.1e-3)**2 )**(3./2.) 68 | return 69 | 70 | def set_forcing(self): 71 | M=self.fortran.main_module 72 | return 73 | 74 | def set_diagnostics(self): 75 | return 76 | 77 | if __name__ == "__main__": 78 | model = test_tke1() 79 | model.run( snapint = 8640.0, runlen = 365*86400.) 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /py_src/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | include ../site_specific.mk_$(HOSTTYPE) 5 | 6 | code = ../for_src 7 | main = $(code)/main 8 | external = $(code)/external 9 | iso = $(code)/isoneutral 10 | ide = $(code)/idemix 11 | adv = $(code)/advection 12 | dia = $(code)/diagnostics 13 | rossmix = $(code)/rossmix 14 | 15 | 16 | for_files = $(main)/main_module.f90 \ 17 | $(ide)/idemix_module.f90 \ 18 | $(code)/density/density.f90 \ 19 | $(code)/tke/tke_module.f90 \ 20 | $(code)/eke/eke_module.f90 \ 21 | $(code)/obc/obc_module.f90 \ 22 | $(code)/tracer/tracer_module.f90 \ 23 | $(iso)/isoneutral_module.f90 \ 24 | $(code)/etc/timing_module.f90 \ 25 | $(rossmix)/rossmix_module.f90 \ 26 | $(main)/momentum.f90 $(main)/biharmonic_friction.f90 $(main)/numerics.f90 \ 27 | $(main)/harmonic_friction.f90 $(main)/bottom_friction.f90 $(main)/vertical_friction.f90 \ 28 | $(main)/thermodynamics.f90 $(main)/momentum_advection.f90 $(main)/vertical_velocity.f90 \ 29 | $(adv)/adv_main.f90 \ 30 | $(adv)/adv_2nd.f90 $(adv)/adv_dst3.f90 \ 31 | $(adv)/adv_superbee.f90 $(adv)/adv_upwind.f90 $(adv)/adv_upwind3.f90 \ 32 | $(main)/diffusion.f90 $(main)/restart.f90 \ 33 | $(code)/non_hydrostatic/non_hydrostatic.f90 \ 34 | $(code)/obc/obc.f90 $(code)/density/get_rho.f90 \ 35 | $(external)/solve_pressure.f90 $(external)/streamfct_init.f90 \ 36 | $(external)/solve_streamfct.f90 $(external)/island_module.f90 \ 37 | $(iso)/isoneutral_diffusion.f90 $(iso)/isoneutral_friction.f90 \ 38 | $(iso)/isoneutral.f90 $(iso)/isoneutral_ml.f90 \ 39 | $(ide)/idemix.f90 $(ide)/idemix_low_mode.f90 $(ide)/idemix_friction.f90 \ 40 | $(ide)/idemix_spectral.f90 $(ide)/idemix_group_vel.f90 $(ide)/idemix3.f90 $(ide)/idemix_leewaves.f90 \ 41 | $(rossmix)/rossmix.f90 $(rossmix)/rossmix_flux.f90 $(rossmix)/rossmix_integrate.f90 \ 42 | $(rossmix)/rossmix_friction.f90 $(rossmix)/rossmix_group_velocity.f90 \ 43 | $(rossmix)/rossmix_reflect.f90 \ 44 | $(code)/tke/tke.f90 $(code)/eke/eke.f90 $(code)/tracer/tracer.f90 \ 45 | $(dia)/diag_particles.f90 $(code)/etc/py_stuff.f90 46 | 47 | 48 | all : pyOM_code.so pyOM_code_MPI.so 49 | 50 | pyOM_code.so: $(for_files) $(code)/parallel/parallel_none.f90 51 | f2py -c $(for_files) $(code)/parallel/parallel_none.f90 -m pyOM_code ${F2PYFLAGS} 52 | 53 | pyOM_code_MPI.so: $(for_files) $(code)/parallel/parallel_mpi.f90 54 | f2py -c $(for_files) $(code)/parallel/parallel_mpi.f90 -m pyOM_code_MPI ${F2PYFLAGS} ${F2PY_MPIFLAGS} 55 | 56 | clean: 57 | (cd ${code}; make clean) 58 | rm -f *.so 59 | 60 | 61 | -------------------------------------------------------------------------------- /py_src/pyOM_ave.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import numpy 4 | from pyOM_cdf import pyOM_cdf 5 | 6 | class pyOM_ave(pyOM_cdf): 7 | """ 8 | pyOM_cdf with averaging diagnostics in netcdf format 9 | """ 10 | def __init__(self): 11 | pyOM_cdf.__init__(self) 12 | self.nitts = 0 13 | self.diag = [] 14 | self.set_diagnostics() 15 | return 16 | 17 | def set_diagnostics(self): 18 | """ register variables to be averaged here. This is a dummy routine to be replaced 19 | """ 20 | return 21 | 22 | def diagnose(self): 23 | """ diagnose the model variables 24 | """ 25 | pyOM_cdf.diagnose(self) 26 | self.write_average_cdf() 27 | return 28 | 29 | def time_step(self): 30 | """ do one time step 31 | and calculate cummulative sum of all variables to be averaged 32 | """ 33 | pyOM_cdf.time_step(self) 34 | self.nitts = self.nitts +1 35 | for d in self.diag: 36 | if d['ave'].shape == d['var'].shape: 37 | d['ave'] = d['ave'] + d['var'] 38 | else: 39 | d['ave'] = d['ave'] + d['var'][...,self.fortran.main_module.tau-1] 40 | return 41 | 42 | def register_average(self, name = '', long_name = '', units = '', grid = '', var=None): 43 | """ register a variable to be averaged. grid is string of length (len(var.shape)) 44 | indicating the grid location: 'T' for cell center, 'U' face of cell 45 | """ 46 | #check if name is in use 47 | for d in self.diag: 48 | if d['name'] == name: 49 | print(' name already in use') 50 | return 51 | # append diagnostics 52 | self.diag.append({'name':name,'long_name':long_name,'units':units,'grid':grid} ) 53 | self.diag[-1]['var']=var 54 | if var.shape[-1] == 3: 55 | self.diag[-1]['ave'] = numpy.zeros( var.shape[:-1], 'd', order='F') 56 | else: 57 | self.diag[-1]['ave'] = numpy.zeros( var.shape, 'd', order='F') 58 | return 59 | 60 | def write_average_cdf(self): 61 | """ write averaged variables to netCDF file 62 | """ 63 | M=self.fortran.main_module 64 | ave_file = ('average_%12i.cdf'%M.itt).replace(' ','0') 65 | 66 | self.define_grid_cdf(ave_file) 67 | if (M.my_pe == 0): 68 | #print "writing to file ",ave_file 69 | fid = self.NF(ave_file,'a') 70 | for d in self.diag: 71 | dims = [] 72 | if d['grid'][0] == 'T': dims.append('xt') 73 | elif d['grid'][0] == 'U': dims.append('xu') 74 | else: raise pyOMError('unkown grid in averaged variable' + d['name']) 75 | 76 | if d['grid'][1] == 'T': dims.append('yt') 77 | elif d['grid'][1] == 'U': dims.append('yu') 78 | else: raise pyOMError('unkown grid in averaged variable' + d['name']) 79 | 80 | if len(d['grid']) >2: 81 | if d['grid'][2] == 'T': dims.append('zt') 82 | elif d['grid'][2] == 'U': dims.append('zw') 83 | else: raise pyOMError('unkown grid in averaged variable' + d['name']) 84 | dims.append('Time') 85 | id=fid.createVariable(d['name'],'f',tuple(dims[::-1]) ) 86 | id.long_name = d['long_name']; id.units=d['units'] 87 | id.missing_value = self._spval 88 | 89 | if (M.my_pe == 0): 90 | tid=fid.variables['Time']; 91 | i=list(numpy.shape(tid))[0]; 92 | tid[i]=M.itt*M.dt_tracer 93 | 94 | a = numpy.zeros( (M.nx,M.ny) , 'd', order='F') 95 | NaN = a+self._spval 96 | 97 | for d in self.diag: 98 | 99 | if len(d['grid']) >2: 100 | if d['grid'] == 'TTT' : mask = M.maskt 101 | elif d['grid'] == 'UTT' : mask = M.masku 102 | elif d['grid'] == 'TUT' : mask = M.maskv 103 | elif d['grid'] == 'TTU' : mask = M.maskw 104 | elif d['grid'] == 'UUT' : mask = M.maskz 105 | else: raise pyOMError('unkown grid in averaged variable' + d['name']) 106 | else: 107 | if d['grid'] == 'TT' : mask = M.maskt[:,:,-1] 108 | elif d['grid'] == 'UT' : mask = M.masku[:,:,-1] 109 | elif d['grid'] == 'TU' : mask = M.maskv[:,:,-1] 110 | elif d['grid'] == 'UU' : mask = M.maskz[:,:,-1] 111 | else: raise pyOMError('unkown grid in averaged variable' + d['name']) 112 | 113 | if len(d['ave'].shape)==2: 114 | a[ M.is_pe-1:M.ie_pe, M.js_pe-1:M.je_pe] = self.mask_me(d['ave'][:]/max(1,self.nitts),mask) 115 | self.fortran.pe0_recv_2d(a) 116 | if M.my_pe == 0: fid.variables[d['name']][i,:] = a.transpose().astype('f') 117 | elif len( d['ave'].shape )==3: 118 | for k in range(M.nz): 119 | a[ M.is_pe-1:M.ie_pe, M.js_pe-1:M.je_pe] = self.mask_me(d['ave'][:,:,k]/max(1,self.nitts),mask[:,:,k]) 120 | self.fortran.pe0_recv_2d(a) 121 | if M.my_pe == 0: fid.variables[d['name']][i,k,:] = a.transpose().astype('f') 122 | else: 123 | raise pyOMError('unexpected shape for averaged variable' + d['name']) 124 | 125 | self.nitts = 0 126 | for d in self.diag: d['ave']=d['ave']*0 127 | 128 | if M.my_pe == 0: fid.close() 129 | return 130 | 131 | 132 | 133 | if __name__ == "__main__": 134 | print('I will do nothing') 135 | -------------------------------------------------------------------------------- /site_specific.mk_amd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | # for mac osx 7 | 8 | F90 = mpif90 9 | #F90FLAGS = -fconvert=big-endian -O3 -Wall 10 | F90FLAGS = -llapack -lblas -fconvert=big-endian -O3 -Wall\ 11 | -fbounds-check -finit-real=nan -finit-integer=nan -fallow-argument-mismatch 12 | CDFFLAGS = -I/usr/local/include -L/usr/local/lib -lnetcdff -lnetcdf -lnetcdf 13 | MPIFLAGS = 14 | 15 | F2PYFLAGS = -llapack -lblas 16 | F2PY_MPIFLAGS = 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /site_specific.mk_intel-mac: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | # for mac osx 7 | 8 | F90 = mpif90 9 | #F90FLAGS = -fconvert=big-endian -O3 -Wall 10 | F90FLAGS = -llapack -lblas -fconvert=big-endian -O3 -Wall\ 11 | -fbounds-check -finit-real=nan -finit-integer=nan -fallow-argument-mismatch 12 | CDFFLAGS = -I/usr/local/include -L/usr/local/lib -lnetcdff -lnetcdf -lnetcdf 13 | MPIFLAGS = 14 | 15 | F2PYFLAGS = -llapack -lblas 16 | F2PY_MPIFLAGS = 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /site_specific.mk_levante: -------------------------------------------------------------------------------- 1 | 2 | # need to load modules: 3 | # module purge 4 | #module load intel-oneapi-compilers 5 | #module load intel-oneapi-mkl 6 | #module load openmpi 7 | #module load netcdf-c 8 | #module load netcdf-fortran 9 | 10 | # fortran front end 11 | F90 = mpifort 12 | CDFFLAGS = -I`nf-config --includedir` `nf-config --flibs` 13 | MPIFLAGS = 14 | F90FLAGS = -Wl,-rpath,`nf-config --prefix `/lib -qmkl -Wl,-rpath,${MKLROOT}/lib/intel64 -convert big_endian 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /site_specific.mk_mistral: -------------------------------------------------------------------------------- 1 | 2 | # need to load modules: 3 | # module purge 4 | # module load gcc/4.8.2 openmpi/1.8.4-gcc48 5 | 6 | 7 | # netcdf library 8 | cdf = /sw/rhel6-x64/netcdf/netcdf_fortran-4.4.2-gcc48/bin/nf-config 9 | 10 | 11 | lapackdir = /sw/rhel6-x64/numerics/netlib_lapack-3.5.0-gcc48/lib 12 | blasdir = /sw/rhel6-x64/numerics/openblas-0.2.14-haswell-gcc48/lib 13 | 14 | # fortran front end 15 | F90 = mpif90 16 | CDFFLAGS = -I`$(cdf) --includedir` `$(cdf) --flibs` 17 | MPIFLAGS = 18 | #F90FLAGS = -O0 -xCORE-AVX2 19 | F90FLAGS = -L$(lapackdir) -l:liblapack_LINUX.a -L$(blasdir) -l:libopenblas.a -fconvert=big-endian -O3 -Wall 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /site_specific.mk_thunder: -------------------------------------------------------------------------------- 1 | 2 | # on thunder: need to load modules 3 | # module purge 4 | # module load gcc/4.4.5 openmpi/1.6.5-gccsys python mpi4py 5 | # use the compiler version compatible for python version 6 | # seen invoking python interpreter commandline 7 | 8 | # netcdf library 9 | cdf = /sw/squeeze-x64/netcdf-4.1.3-static-gccsys/bin/nc-config 10 | 11 | # mpi library 12 | mpi = /sw/squeeze-x64/mpilib/openmpi-1.6.5-gccsys 13 | # to get mpi lib we have to set 14 | # export LD_LIBRARY_PATH="$mpi/lib" 15 | 16 | # fortran front end 17 | F90 = mpif90 18 | CDFFLAGS = -I`$(cdf) --includedir` `$(cdf) --flibs` 19 | MPIFLAGS = 20 | F90FLAGS = -llapack -lblas -fconvert=big-endian -O3 -Wall #-check bounds 21 | 22 | # python front end 23 | F2PYFLAGS = -llapack -lblas 24 | F2PY_MPIFLAGS = -I$(mpi)/include $(mpi)/lib/libmpi_f77.so 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /site_specific.mk_x86_64-linux: -------------------------------------------------------------------------------- 1 | 2 | 3 | # for generic linux, e.g. ubuntu 64bit 4 | 5 | F90 = mpif90 6 | CDFFLAGS = -I/usr/include -lnetcdf -lnetcdff 7 | MPIFLAGS = -I/usr/include/mpi -lmpi 8 | F90FLAGS = -fconvert=big-endian -llapack -lblas -O3 -fbounds-check -finit-real=nan -finit-integer=nan -Wall 9 | 10 | F2PYFLAGS = -llapack -lblas 11 | F2PY_MPIFLAGS = -I/usr/include/mpi -lmpi -lmpi_mpifh 12 | 13 | 14 | 15 | 16 | --------------------------------------------------------------------------------