MODULE opa !!============================================================================== !! *** MODULE opa *** !! Ocean system : OPA ocean dynamics (including on-line tracers and sea-ice) !!============================================================================== !! History : OPA ! 1990-10 (C. Levy, G. Madec) Original code !! 7.0 ! 1991-11 (M. Imbard, C. Levy, G. Madec) !! 7.1 ! 1993-03 (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, !! P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes ) release 7.1 !! - ! 1992-06 (L.Terray) coupling implementation !! - ! 1993-11 (M.A. Filiberti) IGLOO sea-ice !! 8.0 ! 1996-03 (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, !! P. Delecluse, L.Terray, M.A. Filiberti, J. Vialar, A.M. Treguier, M. Levy) release 8.0 !! 8.1 ! 1997-06 (M. Imbard, G. Madec) !! 8.2 ! 1999-11 (M. Imbard, H. Goosse) LIM sea-ice model !! ! 1999-12 (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols) OPEN-MP !! ! 2000-07 (J-M Molines, M. Imbard) Open Boundary Conditions (CLIPPER) !! NEMO 1.0 ! 2002-08 (G. Madec) F90: Free form and modules !! - ! 2004-06 (R. Redler, NEC CCRLE, Germany) add OASIS[3/4] coupled interfaces !! - ! 2004-08 (C. Talandier) New trends organization !! - ! 2005-06 (C. Ethe) Add the 1D configuration possibility !! - ! 2005-11 (V. Garnier) Surface pressure gradient organization !! - ! 2006-03 (L. Debreu, C. Mazauric) Agrif implementation !! - ! 2006-04 (G. Madec, R. Benshila) Step reorganization !! - ! 2007-07 (J. Chanut, A. Sellar) Unstructured open boundaries (BDY) !! 3.2 ! 2009-08 (S. Masson) open/write in the listing file in mpp !!---------------------------------------------------------------------- !!---------------------------------------------------------------------- !! opa_model : solve ocean dynamics, tracer and/or sea-ice !! opa_init : initialization of the opa model !! opa_flg : initialisation of algorithm flag !! opa_closefile : close remaining files !!---------------------------------------------------------------------- USE oce ! dynamics and tracers variables USE dom_oce ! ocean space domain variables USE sbc_oce ! surface boundary condition: ocean USE trdmod_oce ! ocean variables trends USE domcfg ! domain configuration (dom_cfg routine) USE mppini ! shared/distributed memory setting (mpp_init routine) USE domain ! domain initialization (dom_init routine) USE obc_par ! open boundary cond. parameters USE obcini ! open boundary cond. initialization (obc_ini routine) USE bdy_par ! unstructured open boundary cond. parameters USE bdyini ! unstructured open boundary cond. initialization (bdy_init routine) USE istate ! initial state setting (istate_init routine) USE sbcmod ! surface boundary condition USE eosbn2 ! equation of state (eos_init routine) USE dynhpg ! hydrostatic pressure gradient USE ldfdyn ! lateral viscosity setting (ldfdyn_init routine) USE ldftra ! lateral diffusivity setting (ldftra_init routine) USE zdfini USE phycst ! physical constant (par_cst routine) USE trdmod ! momentum/tracers trends (trd_mod_init routine) USE diaptr ! poleward transports (dia_ptr_init routine) USE step ! OPA time-stepping (stp routine) #if defined key_oasis3 USE cpl_oasis3 ! OASIS3 coupling #elif defined key_oasis4 USE cpl_oasis4 ! OASIS4 coupling (not working) #endif USE dynspg_oce ! Control choice of surface pressure gradient schemes USE prtctl ! Print control (prt_ctl_init routine) USE c1d ! 1D configuration USE dyncor_c1d ! Coriolis factor at T-point USE step_c1d ! Time stepping loop for the 1D configuration #if defined key_top USE trcini ! passive tracer initialisation #endif USE iom USE in_out_manager ! I/O manager USE lib_mpp ! distributed memory computing #if defined key_iomput USE mod_ioclient #endif IMPLICIT NONE PRIVATE PUBLIC opa_model ! called by model.F90 PUBLIC opa_init ! needed by AGRIF CHARACTER (len=64) :: cform_aaa="( /, 'AAAAAAAA', / ) " ! flag for output listing !!---------------------------------------------------------------------- !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009) !! $Id$ !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) !!---------------------------------------------------------------------- CONTAINS SUBROUTINE opa_model !!---------------------------------------------------------------------- !! *** ROUTINE opa *** !! !! ** Purpose : opa solves the primitive equations on an orthogonal !! curvilinear mesh on the sphere. !! !! ** Method : - model general initialization !! - launch the time-stepping (stp routine) !! - finalize the run by closing files and communications !! !! References : Madec, Delecluse,Imbard, and Levy, 1997: internal report, IPSL. !! Madec, 2008, internal report, IPSL. !!---------------------------------------------------------------------- INTEGER :: istp ! time step index !!---------------------------------------------------------------------- #if defined key_agrif CALL Agrif_Init_Grids() ! AGRIF: set the meshes #endif ! !-----------------------! CALL opa_init !== Initialisations ==! ! !-----------------------! ! check that all process are still there... If some process have an error, ! they will never enter in step and other processes will wait until the end of the cpu time! IF( lk_mpp ) CALL mpp_max( nstop ) IF(lwp) WRITE(numout,cform_aaa) ! Flag AAAAAAA ! !-----------------------! ! !== time stepping ==! ! !-----------------------! istp = nit000 IF( lk_c1d ) THEN !== 1D configuration ==! DO WHILE ( istp <= nitend .AND. nstop == 0 ) CALL stp_c1d( istp ) istp = istp + 1 END DO ELSE !== 3D ocean with ==! DO WHILE ( istp <= nitend .AND. nstop == 0 ) #if defined key_agrif CALL Agrif_Step( stp ) ! AGRIF: time stepping #else CALL stp( istp ) ! standard time stepping #endif istp = istp + 1 IF( lk_mpp ) CALL mpp_max( nstop ) END DO ENDIF ! !------------------------! ! !== finalize the run ==! ! !------------------------! IF(lwp) WRITE(numout,cform_aaa) ! Flag AAAAAAA ! IF( nstop /= 0 .AND. lwp ) THEN ! error print WRITE(numout,cform_err) WRITE(numout,*) nstop, ' error have been found' ENDIF ! CALL opa_closefile #if defined key_oasis3 || defined key_oasis4 IF( Agrif_Root() ) THEN CALL cpl_prism_finalize ! end coupling and mpp communications with OASIS ENDIF #else IF( lk_mpp ) CALL mppstop ! end mpp communications #endif ! END SUBROUTINE opa_model SUBROUTINE opa_init !!---------------------------------------------------------------------- !! *** ROUTINE opa_init *** !! !! ** Purpose : initialization of the opa model !! !!---------------------------------------------------------------------- #if defined key_oasis3 || defined key_oasis4 || defined key_iomput INTEGER :: ilocal_comm #endif CHARACTER(len=80),dimension(10) :: cltxt = '' INTEGER :: ji ! local loop indices !! NAMELIST/namctl/ ln_ctl , nn_print, nn_ictls, nn_ictle, & & nn_isplt, nn_jsplt, nn_jctls, nn_jctle, nn_bench, nn_bit_cmp !!---------------------------------------------------------------------- ! ! ! open Namelist file CALL ctl_opn( numnam, 'namelist', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. ) ! READ( numnam, namctl ) ! Namelist namctl : Control prints & Benchmark ! ! !--------------------------------------------! ! ! set communicator & select the local node ! ! !--------------------------------------------! #if defined key_iomput # if defined key_oasis3 || defined key_oasis4 IF( Agrif_Root() ) THEN CALL cpl_prism_init( ilocal_comm ) ! nemo local communicator given by oasis CALL init_ioclient() ! io_server will get its communicators (if needed) from oasis (we don't see it) ENDIF # else IF( Agrif_Root() ) THEN CALL init_ioclient( ilocal_comm ) ! nemo local communicator (used or not) given by the io_server ENDIF # endif narea = mynode( cltxt, ilocal_comm ) ! Nodes selection #else # if defined key_oasis3 || defined key_oasis4 IF( Agrif_Root() ) THEN CALL cpl_prism_init( ilocal_comm ) ! nemo local communicator given by oasis ENDIF narea = mynode( cltxt, ilocal_comm ) ! Nodes selection (control print return in cltxt) # else narea = mynode( cltxt ) ! Nodes selection (control print return in cltxt) # endif #endif narea = narea + 1 ! mynode return the rank of proc (0 --> jpnij -1 ) lwp = (narea == 1) .OR. ln_ctl ! control of all listing output print IF(lwp) THEN ! open listing units ! CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea ) ! WRITE(numout,*) WRITE(numout,*) ' CNRS - NERC - Met OFFICE - MERCATOR-ocean' WRITE(numout,*) ' NEMO team' WRITE(numout,*) ' Ocean General Circulation Model' WRITE(numout,*) ' version 3.2 (2009) ' WRITE(numout,*) WRITE(numout,*) DO ji = 1, SIZE(cltxt) IF( TRIM(cltxt(ji)) /= '' ) WRITE(numout,*) cltxt(ji) ! control print of mynode END DO WRITE(numout,cform_aaa) ! Flag AAAAAAA ! ENDIF ! !--------------------------------! ! ! Model general initialization ! ! !--------------------------------! CALL opa_flg ! Control prints & Benchmark ! Domain decomposition IF( jpni*jpnj == jpnij ) THEN ; CALL mpp_init ! standard cutting out ELSE ; CALL mpp_init2 ! eliminate land processors ENDIF CALL phy_cst ! Physical constants CALL eos_init ! Equation of state CALL dom_cfg ! Domain configuration CALL dom_init ! Domain !!gm c1d case can be moved in dom_init routine IF( lk_c1d ) THEN ! 1D configuration CALL cor_c1d ! Coriolis defined at T-point umask(:,:,:) = tmask(:,:,:) ! U, V and T-points are the same vmask(:,:,:) = tmask(:,:,:) ! ENDIF !!gm c1d end IF( ln_ctl ) CALL prt_ctl_init ! Print control IF( lk_obc ) CALL obc_init ! Open boundaries IF( lk_bdy ) CALL bdy_init ! Unstructured open boundaries CALL istate_init ! ocean initial state (Dynamics and tracers) ! ! Ocean physics CALL sbc_init ! Read namsbc namelist : surface module (needed for iom_init) CALL ldf_tra_init ! Lateral ocean tracer physics CALL ldf_dyn_init ! Lateral ocean momentum physics CALL zdf_init ! Vertical ocean physics #if defined key_top CALL trc_ini ! Passive tracers #endif ! ! diagnostics CALL iom_init ! iom_put initialization CALL dia_ptr_init ! Poleward TRansports initialization CALL trd_mod_init ! Mixed-layer/Vorticity/Integral constraints trends ! END SUBROUTINE opa_init SUBROUTINE opa_flg !!---------------------------------------------------------------------- !! *** ROUTINE opa *** !! !! ** Purpose : Initialise logical flags that control the choice of !! some algorithm or control print !! !! ** Method : - print namctl information !! - Read in namilist namflg logical flags !!---------------------------------------------------------------------- NAMELIST/namdyn_hpg/ ln_hpg_zco , ln_hpg_zps , ln_hpg_sco, ln_hpg_hel, & & ln_hpg_wdj , ln_hpg_djc , ln_hpg_rot, rn_gamma , & & ln_dynhpg_imp, nn_dynhpg_rst !!---------------------------------------------------------------------- IF(lwp) THEN ! Parameter print WRITE(numout,*) WRITE(numout,*) 'opa_flg: Control prints & Benchmark' WRITE(numout,*) '~~~~~~~ ' WRITE(numout,*) ' Namelist namctl' WRITE(numout,*) ' run control (for debugging) ln_ctl = ', ln_ctl WRITE(numout,*) ' level of print nn_print = ', nn_print WRITE(numout,*) ' Start i indice for SUM control nn_ictls = ', nn_ictls WRITE(numout,*) ' End i indice for SUM control nn_ictle = ', nn_ictle WRITE(numout,*) ' Start j indice for SUM control nn_jctls = ', nn_jctls WRITE(numout,*) ' End j indice for SUM control nn_jctle = ', nn_jctle WRITE(numout,*) ' number of proc. following i nn_isplt = ', nn_isplt WRITE(numout,*) ' number of proc. following j nn_jsplt = ', nn_jsplt WRITE(numout,*) ' benchmark parameter (0/1) nn_bench = ', nn_bench WRITE(numout,*) ' bit comparison mode (0/1) nn_bit_cmp = ', nn_bit_cmp ENDIF nprint = nn_print ! convert DOCTOR namelist names into OLD names nictls = nn_ictls nictle = nn_ictle njctls = nn_jctls njctle = nn_jctle isplt = nn_isplt jsplt = nn_jsplt nbench = nn_bench nbit_cmp = nn_bit_cmp ! ! Parameter control ! IF( ln_ctl ) THEN ! sub-domain area indices for the control prints IF( lk_mpp ) THEN isplt = jpni ; jsplt = jpnj ; ijsplt = jpni*jpnj ! the domain is forced to the real splitted domain ELSE IF( isplt == 1 .AND. jsplt == 1 ) THEN CALL ctl_warn( ' - isplt & jsplt are equal to 1', & & ' - the print control will be done over the whole domain' ) ENDIF ijsplt = isplt * jsplt ! total number of processors ijsplt ENDIF IF(lwp) WRITE(numout,*)' - The total number of processors over which the' IF(lwp) WRITE(numout,*)' print control will be done is ijsplt : ', ijsplt ! ! ! indices used for the SUM control IF( nictls+nictle+njctls+njctle == 0 ) THEN ! print control done over the default area lsp_area = .FALSE. ELSE ! print control done over a specific area lsp_area = .TRUE. IF( nictls < 1 .OR. nictls > jpiglo ) THEN CALL ctl_warn( ' - nictls must be 1<=nictls>=jpiglo, it is forced to 1' ) nictls = 1 ENDIF IF( nictle < 1 .OR. nictle > jpiglo ) THEN CALL ctl_warn( ' - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' ) nictle = jpiglo ENDIF IF( njctls < 1 .OR. njctls > jpjglo ) THEN CALL ctl_warn( ' - njctls must be 1<=njctls>=jpjglo, it is forced to 1' ) njctls = 1 ENDIF IF( njctle < 1 .OR. njctle > jpjglo ) THEN CALL ctl_warn( ' - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' ) njctle = jpjglo ENDIF ENDIF ENDIF IF( nbench == 1 ) THEN ! Benchmark SELECT CASE ( cp_cfg ) CASE ( 'gyre' ) ; CALL ctl_warn( ' The Benchmark is activated ' ) CASE DEFAULT ; CALL ctl_stop( ' The Benchmark is based on the GYRE configuration:', & & ' key_gyre must be used or set nbench = 0' ) END SELECT ENDIF IF( nbit_cmp == 1 ) THEN ! Bit compare CALL ctl_warn( ' Bit comparison enabled. Single and multiple processor results must bit compare', & & ' WARNING: RESULTS ARE NOT PHYSICAL.' ) ENDIF REWIND( numnam ) ! Read Namelist namdyn_hpg : ln_dynhpg_imp must be read at the initialisation phase READ ( numnam, namdyn_hpg ) ! END SUBROUTINE opa_flg SUBROUTINE opa_closefile !!---------------------------------------------------------------------- !! *** ROUTINE opa_closefile *** !! !! ** Purpose : Close the files !!---------------------------------------------------------------------- USE dtatem ! temperature data USE dtasal ! salinity data !!---------------------------------------------------------------------- ! IF( lk_mpp ) CALL mppsync ! CALL iom_close ! close all input/output files managed by iom_* ! IF( numstp /= -1 ) CLOSE( numstp ) ! time-step file IF( numsol /= -1 ) CLOSE( numsol ) ! solver file IF( numnam /= -1 ) CLOSE( numnam ) ! oce namelist IF( numnam_ice /= -1 ) CLOSE( numnam_ice ) ! ice namelist IF( numevo_ice /= -1 ) CLOSE( numevo_ice ) ! ice variables (temp. evolution) IF( numout /= 6 ) CLOSE( numout ) ! standard model output file numout = 6 ! redefine numout in case it is used after this point... ! END SUBROUTINE opa_closefile !!====================================================================== END MODULE opa