Changeset 3282 for trunk/LMDZ.MARS
- Timestamp:
- Mar 21, 2024, 7:52:55 AM (8 months ago)
- Location:
- trunk/LMDZ.MARS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/changelog.txt
r3274 r3282 4578 4578 == 20/03/2024 == LL 4579 4579 Small update of soil properties (porosity) when running soilwater to simulate the evolution of massive water ice 4580 4581 == 21/03/2024 == EM 4582 Fix a buggy behavior of wstats: it would fail when using a stats.def file and 4583 when the first (at every time step) variable sent to wstats() was not part of 4584 those listed in stats.def -
trunk/LMDZ.MARS/libf/phymars/wstats_mod.F90
r2997 r3282 26 26 ! Main routine to call to trigger writing a given field to the "stats.nc" file 27 27 28 use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather, klon_mpi_begin 28 use mod_phys_lmdz_para, only : is_mpi_root, is_master, klon_mpi_begin 29 use mod_phys_lmdz_transfert_para, only: gather, bcast 29 30 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo, & 30 31 nbp_lon, nbp_lat, nbp_lev, & … … 53 54 54 55 ! Added to read an optional stats.def file to select outputs 56 logical,save :: check_stats_def=.TRUE. ! to keep track of if stats.def was checked 55 57 logical,save :: stats_def ! .true. if there is a stats.def file 56 58 integer,save :: n_name_def ! number of fields to output in stats.nc 57 ! NB: stats_def and n_name_def do not need be threadprivate58 59 integer,parameter :: n_name_def_max=199 ! max number of fields to output 59 60 character(len=120),save :: name_def(n_name_def_max) 60 61 logical :: getout ! to trigger an early exit if variable not in output list 61 62 62 !$OMP THREADPRIVATE( stats_def,n_name_def,name_def)63 !$OMP THREADPRIVATE(check_stats_def,stats_def,n_name_def,name_def) 63 64 64 65 ! Added to work in parallel mode … … 89 90 endif 90 91 91 ! 1. Initialization (creation of stats.nc file) 92 if (firstcall) then 93 firstcall=.false. 94 95 !$OMP MASTER 96 ! open stats.def definition file if there is one 97 open(99,file="stats.def",status='old',form='formatted',& 98 iostat=ierr) 99 if (ierr.eq.0) then 92 if (check_stats_def) then 93 ! this step only needs be made a single unique time 94 ! hence the chack_stats_def flag. 95 96 if (is_master) then 97 ! Only the master reads the file 98 ! open stats.def definition file if there is one 99 open(99,file="stats.def",status='old',form='formatted',& 100 iostat=ierr) 101 if (ierr.eq.0) then 100 102 stats_def=.true. ! yes there is a stats.def file 101 103 write(*,*) "*****************" … … 114 116 n_name_def=n-1 115 117 close(99) 116 else118 else 117 119 stats_def=.false. ! no stats.def file; output all fields sent to wstats 118 endif ! of if (ierr.eq.0) 119 !$OMP END MASTER 120 !$OMP BARRIER 121 122 firstvar=trim((nom)) 120 endif ! of if (ierr.eq.0) 121 122 endif ! of if (is_master) 123 124 ! share the info gathered by master with all other cores 125 call bcast(stats_def) 126 call bcast(n_name_def) 127 do n=1,n_name_def 128 call bcast(name_def(n)) 129 enddo 130 131 check_stats_def=.false. 132 endif ! of if (check_stats_def) 133 134 ! 1. Initialization (creation of stats.nc file) 135 if (firstcall) then 136 firstcall=.false. 137 138 ! identify the first variable name with which wstats is called in 139 ! a time step 140 if (stats_def) then 141 ! check if "nom" is in the wanted output list. If it is then 142 ! it is the sought "first variable"; if not then skip all the 143 ! rest and reset "firstcall" to true 144 getout=.true. 145 do n=1,n_name_def 146 ! look for the variable's name in the list 147 if (trim(name_def(n)).eq.nom) then 148 getout=.false. 149 ! found it, no need to scan the rest of the list exit loop 150 firstvar=trim((nom)) 151 exit 152 endif 153 enddo 154 if (getout) then 155 ! variable not in the list so exit routine now 156 firstcall=.true. 157 return 158 endif 159 else 160 ! without a stats.def, the very first call to stats contains first 161 ! variable name 162 firstvar=trim((nom)) 163 endif ! of if (stats_def) 164 165 ! initialize stats.nc file 123 166 call inistats(ierr) 167 168 ! allocate arrays that will be needed later 124 169 if (klon_glo>1) then ! general case, 3D GCM 125 170 allocate(mean3d(nbp_lon+1,nbp_lat,nbp_lev)) … … 137 182 allocate(dx2(1,1)) 138 183 endif 184 139 185 endif ! of if (firstcall) 140 186
Note: See TracChangeset
for help on using the changeset viewer.