Changeset 1130
- Timestamp:
- Dec 20, 2013, 4:04:56 PM (11 years ago)
- Location:
- trunk/LMDZ.MARS
- Files:
-
- 17 added
- 5 deleted
- 35 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/README
r1127 r1130 1965 1965 - Bug fix in thermcall_main_mars, layer thickness "zdz" must be recomputed 1966 1966 in every do ig=1,ngrid loop. 1967 1968 == 20/12/2013 == EM 1969 Series of changes to enable running in parallel (using LMDZ.COMMON dynamics); 1970 Current LMDZ.MARS can still notheless be compiled and run in serial mode 1971 "as previously". 1972 Summary of main changes: 1973 - Main programs (newstart, start2archive, xvik) that used to be in dyn3d have 1974 been moved to phymars. 1975 - dyn3d/control.h is now module control_mod.F90 1976 - rearanged input/outputs routines everywhere to handle serial/MPI cases. 1977 physdem.F => phyredem.F90 , phyetat0.F => phyetat0.F90 ; all read/write 1978 routines for startfi files are gathered in module iostart.F90 1979 - added parallelism related routines init_phys_lmdz.F90, comgeomphy.F90, 1980 dimphy.F90, iniphysiq.F90, mod_grid_phy_lmdz.F90, mod_phys_lmdz_mpi_data.F90, 1981 mod_phys_lmdz_mpi_transfert.F90, mod_phys_lmdz_omp_data.F90, 1982 mod_phys_lmdz_omp_transfert.F90, mod_phys_lmdz_para.F90, 1983 mod_phys_lmdz_transfert_para.F90 in phymars 1984 and mod_const_mpi.F90 in dyn3d (for compliance with parallel case) 1985 - created generic routines 'planetwide_maxval' and 'planetwide_minval', in 1986 module "planetwide_mod", that enable obtaining the min and max of a field 1987 over the whole planet. -
trunk/LMDZ.MARS/libf/dyn3d/calfis.F
r1036 r1130 71 71 #include "comvert.h" 72 72 #include "comgeom2.h" 73 #include "control.h"73 !#include "control.h" 74 74 75 75 c Arguments : … … 167 167 168 168 c 169 IF (firstcal) THEN170 latfi(1)=rlatu(1)171 lonfi(1)=0.172 DO j=2,jjm173 DO i=1,iim174 latfi((j-2)*iim+1+i)= rlatu(j)175 lonfi((j-2)*iim+1+i)= rlonv(i)176 ENDDO177 ENDDO178 latfi(ngridmx)= rlatu(jjp1)179 lonfi(ngridmx)= 0.180 181 ! build airefi(), mesh area on physics grid182 CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)183 ! Poles are single points on physics grid184 airefi(1)=airefi(1)*iim185 airefi(ngridmx)=airefi(ngridmx)*iim186 187 CALL inifis(ngridmx,llm,nq,day_ini,daysec,dtphys,188 . latfi,lonfi,airefi,rad,g,r,cpp)189 ENDIF169 ! IF (firstcal) THEN 170 ! latfi(1)=rlatu(1) 171 ! lonfi(1)=0. 172 ! DO j=2,jjm 173 ! DO i=1,iim 174 ! latfi((j-2)*iim+1+i)= rlatu(j) 175 ! lonfi((j-2)*iim+1+i)= rlonv(i) 176 ! ENDDO 177 ! ENDDO 178 ! latfi(ngridmx)= rlatu(jjp1) 179 ! lonfi(ngridmx)= 0. 180 ! 181 ! ! build airefi(), mesh area on physics grid 182 ! CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi) 183 ! ! Poles are single points on physics grid 184 ! airefi(1)=airefi(1)*iim 185 ! airefi(ngridmx)=airefi(ngridmx)*iim 186 ! 187 ! CALL inifis(ngridmx,llm,nq,day_ini,daysec,dtphys, 188 ! . latfi,lonfi,airefi,rad,g,r,cpp) 189 ! ENDIF 190 190 191 191 c -
trunk/LMDZ.MARS/libf/dyn3d/defrun_new.F
r999 r1130 36 36 c -------------- 37 37 ! to use 'getin' 38 USE ioipsl_getincom 38 use ioipsl_getincom, only: getin 39 use control_mod, only: ndynstep, day_step, iperiod, iconser, 40 & idissip, iphysiq, anneeref, ecritphy, 41 & ecritstart, timestart, nday_r 39 42 IMPLICIT NONE 40 43 41 44 #include "dimensions.h" 42 45 #include "paramet.h" 43 #include "control.h"46 !#include "control.h" 44 47 #include "logic.h" 45 48 #include "serre.h" … … 83 86 !le modele martien et ne sont donc plus lues dans "run.def" 84 87 85 anneeref=0 86 ! Note: anneref is a common in 'control.h' 88 anneeref=0 87 89 88 90 OPEN(tapedef,file='run.def',status='old',form='formatted' -
trunk/LMDZ.MARS/libf/dyn3d/dynetat0.F
r1036 r1130 3 3 4 4 use netcdf 5 use infotrac, only: tnom 5 use infotrac, only: tname 6 use control_mod, only: timestart 6 7 7 8 IMPLICIT NONE … … 39 40 #include "logic.h" 40 41 !#include "advtrac.h" 41 #include "control.h"42 !#include "control.h" 42 43 43 44 c Arguments: … … 381 382 ! WRITE(str3(2:3),'(i2.2)') iq 382 383 ! ierr = NF_INQ_VARID (nid, str3, nvarid) 383 ! NB: tracers are now read in using their name ('tn om' from infotrac)384 ! write(*,*) " loading tracer:",trim(tn om(iq))385 ierr=nf90_inq_varid(nid,tn om(iq),nvarid)384 ! NB: tracers are now read in using their name ('tname' from infotrac) 385 ! write(*,*) " loading tracer:",trim(tname(iq)) 386 ierr=nf90_inq_varid(nid,tname(iq),nvarid) 386 387 IF (ierr .NE. nf90_noerr) THEN 387 388 ! PRINT*, "dynetat0: Le champ <"//str3//"> est absent" 388 PRINT*, "dynetat0: Le champ <"//trim(tn om(iq))//389 PRINT*, "dynetat0: Le champ <"//trim(tname(iq))// 389 390 & "> est absent" 390 391 PRINT*, " Il est donc initialise a zero" … … 396 397 IF (ierr .NE. nf90_noerr) THEN 397 398 ! PRINT*, "dynetat0: Lecture echouee pour "//str3 398 PRINT*, "dynetat0: Lecture echouee pour "//trim(tnom(iq))399 PRINT*,"dynetat0: Lecture echouee pour "//trim(tname(iq)) 399 400 CALL abort 400 401 ENDIF -
trunk/LMDZ.MARS/libf/dyn3d/dynredem.F
r1106 r1130 1 1 SUBROUTINE dynredem0(fichnom,idayref,anneeref,phis,nq) 2 use infotrac, only: tn om2 use infotrac, only: tname 3 3 IMPLICIT NONE 4 4 c======================================================================= … … 912 912 ! ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 12, 913 913 ! . "Traceurs "//str3) 914 txt="Traceur "//trim(tn om(iq))915 #ifdef NC_DOUBLE 916 ierr=NF_DEF_VAR(nid,tn om(iq),NF_DOUBLE,4,dims4,nvarid)917 #else 918 ierr=NF_DEF_VAR(nid,tn om(iq),NF_FLOAT,4,dims4,nvarid)914 txt="Traceur "//trim(tname(iq)) 915 #ifdef NC_DOUBLE 916 ierr=NF_DEF_VAR(nid,tname(iq),NF_DOUBLE,4,dims4,nvarid) 917 #else 918 ierr=NF_DEF_VAR(nid,tname(iq),NF_FLOAT,4,dims4,nvarid) 919 919 #endif 920 920 ierr=NF_PUT_ATT_TEXT(nid,nvarid,"title", … … 964 964 SUBROUTINE dynredem1(fichnom,time, 965 965 . vcov,ucov,teta,q,nq,masse,ps) 966 use infotrac, only: nqtot, tn om966 use infotrac, only: nqtot, tname 967 967 IMPLICIT NONE 968 968 c================================================================= … … 1105 1105 ! WRITE(str3(2:3),'(i2.2)') iq 1106 1106 ! ierr = NF_INQ_VARID(nid, str3, nvarid) 1107 ierr=NF_INQ_VARID(nid,tn om(iq),nvarid)1107 ierr=NF_INQ_VARID(nid,tname(iq),nvarid) 1108 1108 IF (ierr .NE. NF_NOERR) THEN 1109 1109 ! PRINT*, "Variable "//str3//" n est pas definie" 1110 PRINT*, "Variable "//trim(tn om(iq))//" n est pas definie"1110 PRINT*, "Variable "//trim(tname(iq))//" n est pas definie" 1111 1111 CALL abort 1112 1112 ENDIF -
trunk/LMDZ.MARS/libf/dyn3d/gcm.F
r1036 r1130 2 2 3 3 use infotrac, only: iniadvtrac, nqtot, iadv 4 use control_mod, only: day_step, iperiod, iphysiq, ndynstep, 5 & nday_r, idissip, iconser, ecritstart, 6 & ecritphy 7 use comgeomphy, only: initcomgeomphy 4 8 IMPLICIT NONE 5 9 … … 42 46 #include "logic.h" 43 47 #include "temps.h" 44 #include "control.h"48 !#include "control.h" 45 49 #include "ener.h" 46 50 #include "netcdf.inc" … … 135 139 logical callgroupeun 136 140 parameter (callgroupeun = .false.) 141 142 c----------------------------------------------------------------------- 143 c variables pour l'initialisation de la physique : 144 c ------------------------------------------------ 145 INTEGER ngridmx 146 PARAMETER( ngridmx = 2+(jjm-1)*iim - 1/jjm ) 147 REAL zcufi(ngridmx),zcvfi(ngridmx) 148 REAL latfi(ngridmx),lonfi(ngridmx) 149 REAL airefi(ngridmx) 150 SAVE latfi, lonfi, airefi 151 INTEGER i,j 152 137 153 c----------------------------------------------------------------------- 138 154 c Initialisations: … … 145 161 c----------------------------------------------------------------------- 146 162 CALL defrun_new( 99, .TRUE. ) 163 164 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 165 ! FH 2008/05/02 166 ! A nettoyer. On ne veut qu'une ou deux routines d'interface 167 ! dynamique -> physique pour l'initialisation 168 !#ifdef CPP_PHYS 169 CALL init_phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/)) 170 call initcomgeomphy 171 !#endif 172 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 147 173 148 174 ! Initialize tracers … … 196 222 c 197 223 224 c----------------------------------------------------------------------- 225 c Initialisation de la physique : 226 c ------------------------------- 227 228 ! IF (call_iniphys.and.(iflag_phys==1.or.iflag_phys>=100)) THEN 229 latfi(1)=rlatu(1) 230 lonfi(1)=0. 231 zcufi(1) = cu(1) 232 zcvfi(1) = cv(1) 233 DO j=2,jjm 234 DO i=1,iim 235 latfi((j-2)*iim+1+i)= rlatu(j) 236 lonfi((j-2)*iim+1+i)= rlonv(i) 237 zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i) 238 zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i) 239 ENDDO 240 ENDDO 241 latfi(ngridmx)= rlatu(jjp1) 242 lonfi(ngridmx)= 0. 243 zcufi(ngridmx) = cu(ip1jm+1) 244 zcvfi(ngridmx) = cv(ip1jm-iim) 245 246 ! build airefi(), mesh area on physics grid 247 CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi) 248 ! Poles are single points on physics grid 249 airefi(1)=airefi(1)*iim 250 airefi(ngridmx)=airefi(ngridmx)*iim 251 252 ! Initialisation de la physique: pose probleme quand on tourne 253 ! SANS physique, car iniphysiq.F est dans le repertoire phy[]... 254 ! Il faut une cle CPP_PHYS 255 !#ifdef CPP_PHYS 256 ! CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys/nsplit_phys, 257 CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys, 258 & latfi,lonfi,airefi,zcufi,zcvfi,rad,g,r,cpp, 259 & 1) 260 ! & iflag_phys) 261 !#endif 262 ! call_iniphys=.false. 263 ! ENDIF ! of IF (call_iniphys.and.(iflag_phys.eq.1)) 264 ! call inifis(ngridmx,llm,nqtot,day_ini,daysec,dtphys, 265 ! . latfi,lonfi,airefi,rad,g,r,cpp) 198 266 199 267 call dump2d(iip1,jjp1,ps,'PRESSION SURFACE') -
trunk/LMDZ.MARS/libf/dyn3d/infotrac.F90
r1036 r1130 5 5 INTEGER, SAVE :: nqtot 6 6 INTEGER,allocatable :: iadv(:) ! tracer advection scheme number 7 CHARACTER(len=20),allocatable :: tn om(:) ! tracer name7 CHARACTER(len=20),allocatable :: tname(:) ! tracer name 8 8 9 9 CONTAINS … … 18 18 IMPLICIT NONE 19 19 20 #include "dimensions.h"20 !#include "dimensions.h" 21 21 !#include "advtrac.h" 22 #include "control.h"22 !#include "control.h" 23 23 24 24 ! routine arguments: … … 47 47 ! allocate arrays: 48 48 allocate(iadv(nq)) 49 allocate(tn om(nq))49 allocate(tname(nq)) 50 50 51 51 ! initialize advection schemes to Van-Leer for all tracers … … 56 56 do iq=1,nq 57 57 ! minimal version, just read in the tracer names, 1 per line 58 read(90,*,iostat=ierr) tn om(iq)58 read(90,*,iostat=ierr) tname(iq) 59 59 if (ierr.ne.0) then 60 60 write(*,*) 'iniadvtrac: error reading tracer names...' -
trunk/LMDZ.MARS/libf/dyn3d/ini_archive.F
r1047 r1130 48 48 #include "description.h" 49 49 #include "serre.h" 50 #include "control.h"50 !#include "control.h" 51 51 !#include"comsoil.h" 52 52 -
trunk/LMDZ.MARS/libf/dyn3d/iniconst.F
r38 r1130 1 1 SUBROUTINE iniconst 2 2 3 use control_mod, only: iphysiq, idissip 3 4 IMPLICIT NONE 4 5 c … … 13 14 #include "comconst.h" 14 15 #include "temps.h" 15 #include "control.h"16 !#include "control.h" 16 17 #include "comvert.h" 17 18 -
trunk/LMDZ.MARS/libf/dyn3d/inidissip.F
r758 r1130 8 8 c ------------- 9 9 10 use control_mod, only: idissip, iperiod 10 11 IMPLICIT NONE 11 12 #include "dimensions.h" … … 14 15 #include "comconst.h" 15 16 #include "comvert.h" 16 #include "control.h"17 !#include "control.h" 17 18 18 19 LOGICAL lstardis -
trunk/LMDZ.MARS/libf/dyn3d/lect_start_archive.F
r1047 r1130 17 17 c 18 18 c======================================================================= 19 use infotrac, only: tn om19 use infotrac, only: tname 20 20 use comsoil_h, only: nsoilmx, layer, mlayer, volcapa, inertiedat 21 21 implicit none … … 32 32 #include "comvert.h" 33 33 #include "comgeom2.h" 34 #include "control.h"34 !#include "control.h" 35 35 #include "logic.h" 36 36 #include "description.h" 37 37 #include "ener.h" 38 38 #include "temps.h" 39 #include "lmdstd.h"39 !#include "lmdstd.h" 40 40 #include "netcdf.inc" 41 41 !#include "tracer.h" … … 760 760 write(txt,'(a5,i2.2)')'qsurf',iq 761 761 ELSE 762 txt=trim(tn om(iq))//"_surf"762 txt=trim(tname(iq))//"_surf" 763 763 if (txt.eq."h2o_vap") then 764 764 ! There is no surface tracer for h2o_vap; … … 948 948 write(txt,'(a1,i2.2)')'q',iq 949 949 ELSE 950 txt=tn om(iq)950 txt=tname(iq) 951 951 ENDIF 952 952 write(*,*)"lect_start_archive: loading tracer ",trim(txt) -
trunk/LMDZ.MARS/libf/dyn3d/write_archive.F
r1047 r1130 38 38 #include "dimphys.h" 39 39 #include "paramet.h" 40 #include "control.h"40 !#include "control.h" 41 41 #include "comvert.h" 42 42 #include "comgeom.h" -
trunk/LMDZ.MARS/libf/dyn3d/writediagdyn.F90
r410 r1130 12 12 ! NB: the rate a which outputs are made can be changed (see parameter isample) 13 13 ! 14 use control_mod, only: iphysiq, day_step 14 15 implicit none 15 16 16 17 #include"dimensions.h" 17 18 #include"paramet.h" 18 #include"control.h"19 !#include"control.h" 19 20 #include"netcdf.inc" 20 21 -
trunk/LMDZ.MARS/libf/phymars/albedocaps.F90
r1047 r1130 6 6 ! to use the 'getin' routine 7 7 use ioipsl_getincom, only: getin 8 #ifdef MESOSCALE 9 use comgeomfi_h 10 #endif 8 use comgeomfi_h, only: lati ! grid point latitudes (rad) 11 9 use surfdat_h, only: TESicealbedo, TESice_Ncoef, TESice_Scoef, & 12 10 emisice, albedice, watercaptag, albedo_h2o_ice, & … … 59 57 60 58 do ig=1,ngrid 61 #ifndef MESOSCALE 62 if (ig.gt.ngrid/2+1) then 63 #else 64 if (lati(ig)*180./acos(-1.).lt.0.) then 65 #endif 59 if (lati(ig).lt.0.) then 66 60 icap=2 ! Southern hemisphere 67 61 else … … 74 68 ! set the surface albedo to be the ice albedo 75 69 if (TESicealbedo) then 76 ! write(*,*) "albedocaps: call TES_icecap_albedo"77 ! write(*,*) "albedocaps: zls=",zls," ig=",ig78 70 call TES_icecap_albedo(zls,ig,psolaralb(ig,1),icap) 79 ! write(*,*) "albedocaps: psolaralb(ig,1)=",psolaralb(ig,1)80 71 psolaralb(ig,2)=psolaralb(ig,1) 81 72 else … … 86 77 ! there is a water ice cap: set the surface albedo to the water ice one 87 78 ! to do : emissivity 88 !write(*,*) "watercaptag in albedocaps:",ig89 79 emisref(ig) = 1 90 80 psolaralb(ig,1)=albedo_h2o_ice … … 105 95 use comgeomfi_h, only: lati, long 106 96 use surfdat_h, only: albedice, TESice_Ncoef, TESice_Scoef 97 use netcdf, only: nf90_open, NF90_NOWRITE, NF90_NOERR, & 98 nf90_strerror, nf90_inq_varid, nf90_get_var, nf90_close 99 107 100 implicit none 108 101 #include"dimensions.h" … … 110 103 !#include"surfdat.h" 111 104 !#include"comgeomfi.h" 112 #include"netcdf.inc"113 105 #include"datafile.h" 114 106 … … 169 161 ! Load TES albedoes for Northern Hemisphere 170 162 ! Note: datafile() is defined in "datafile.h" 171 ierr= NF_OPEN(trim(datafile)//"/npsc_albedo.nc",NF_NOWRITE,nid)172 IF (ierr.NE.NF _NOERR) THEN163 ierr=nf90_open(trim(datafile)//"/npsc_albedo.nc",NF90_NOWRITE,nid) 164 IF (ierr.NE.NF90_NOERR) THEN 173 165 write(*,*)'Problem opening npsc_albedo.nc (phymars/albedocaps.F90)' 174 166 write(*,*)'It should be in :',trim(datafile),'/' … … 179 171 write(*,*)' http://www.lmd.jussieu.fr/~forget/datagcm/datafile' 180 172 CALL ABORT 173 ELSE 174 write(*,*) "albedocaps: using file ",trim(datafile)//"/npsc_albedo.nc" 181 175 ENDIF 182 176 183 ierr= NF_INQ_VARID(nid,"longitude",nvarid)184 if (ierr.ne.NF _NOERR) then177 ierr=nf90_inq_varid(nid,"longitude",nvarid) 178 if (ierr.ne.NF90_NOERR) then 185 179 write(*,*) "Failed to find longitude in file!" 186 else 187 ierr=NF_GET_VAR_REAL(nid,nvarid,TESlon) 188 endif 189 190 ierr=NF_INQ_VARID(nid,"latitude",nvarid) 191 if (ierr.ne.NF_NOERR) then 180 write(*,*)trim(nf90_strerror(ierr)) 181 stop 182 else 183 ierr=nf90_get_var(nid,nvarid,TESlon) 184 if (ierr.ne.NF90_NOERR) then 185 write(*,*) "Failed loading longitude data from file!" 186 write(*,*)trim(nf90_strerror(ierr)) 187 stop 188 endif 189 endif 190 191 ierr=nf90_inq_varid(nid,"latitude",nvarid) 192 if (ierr.ne.NF90_NOERR) then 192 193 write(*,*) "Failed to find latitude in file!" 193 else 194 ierr=NF_GET_VAR_REAL(nid,nvarid,TESlatn) 195 endif 196 197 ierr=NF_INQ_VARID(nid,"time",nvarid) 198 if (ierr.ne.NF_NOERR) then 194 write(*,*)trim(nf90_strerror(ierr)) 195 stop 196 else 197 ierr=nf90_get_var(nid,nvarid,TESlatn) 198 if (ierr.ne.NF90_NOERR) then 199 write(*,*) "Failed loading latitude data from file!" 200 write(*,*)trim(nf90_strerror(ierr)) 201 stop 202 endif 203 endif 204 205 ierr=nf90_inq_varid(nid,"time",nvarid) 206 if (ierr.ne.NF90_NOERR) then 199 207 write(*,*) "Failed to find time in file!" 200 else 201 ierr=NF_GET_VAR_REAL(nid,nvarid,TESls) 202 endif 203 204 ierr=NF_INQ_VARID(nid,"albedo",nvarid) 205 if (ierr.ne.NF_NOERR) then 208 write(*,*)trim(nf90_strerror(ierr)) 209 stop 210 else 211 ierr=nf90_get_var(nid,nvarid,TESls) 212 if (ierr.ne.NF90_NOERR) then 213 write(*,*) "Failed loading time data from file!" 214 write(*,*)trim(nf90_strerror(ierr)) 215 stop 216 endif 217 endif 218 219 ierr=nf90_inq_varid(nid,"albedo",nvarid) 220 if (ierr.ne.NF90_NOERR) then 206 221 write(*,*) "Failed to find albedo in file!" 207 else 208 ierr=NF_GET_VAR_REAL(nid,nvarid,TESalbn) 209 endif 222 write(*,*)trim(nf90_strerror(ierr)) 223 stop 224 else 225 ierr=nf90_get_var(nid,nvarid,TESalbn) 226 if (ierr.ne.NF90_NOERR) then 227 write(*,*) "Failed loading albedo data from file!" 228 write(*,*)trim(nf90_strerror(ierr)) 229 stop 230 endif 231 endif 232 233 ierr=nf90_close(nid) 210 234 211 235 ! Load albedoes for Southern Hemisphere 212 ierr= NF_OPEN(trim(datafile)//"/spsc_albedo.nc",NF_NOWRITE,nid)213 IF (ierr.NE.NF _NOERR) THEN236 ierr=nf90_open(trim(datafile)//"/spsc_albedo.nc",NF90_NOWRITE,nid) 237 IF (ierr.NE.NF90_NOERR) THEN 214 238 write(*,*)'Problem opening spsc_albedo.nc (phymars/albedocaps.F90)' 215 239 write(*,*)'It should be in :',trim(datafile),'/' … … 220 244 write(*,*)' http://www.lmd.jussieu.fr/~forget/datagcm/datafile' 221 245 CALL ABORT 246 ELSE 247 write(*,*) "albedocaps: using file ",trim(datafile)//"/spsc_albedo.nc" 222 248 ENDIF 223 249 224 ierr= NF_INQ_VARID(nid,"latitude",nvarid)225 if (ierr.ne.NF _NOERR) then250 ierr=nf90_inq_varid(nid,"latitude",nvarid) 251 if (ierr.ne.NF90_NOERR) then 226 252 write(*,*) "Failed to find latitude in file!" 227 else 228 ierr=NF_GET_VAR_REAL(nid,nvarid,TESlats) 229 endif 230 231 ierr=NF_INQ_VARID(nid,"albedo",nvarid) 232 if (ierr.ne.NF_NOERR) then 253 write(*,*)trim(nf90_strerror(ierr)) 254 stop 255 else 256 ierr=nf90_get_var(nid,nvarid,TESlats) 257 if (ierr.ne.NF90_NOERR) then 258 write(*,*) "Failed loading latitude data from file!" 259 write(*,*)trim(nf90_strerror(ierr)) 260 stop 261 endif 262 endif 263 264 ierr=nf90_inq_varid(nid,"albedo",nvarid) 265 if (ierr.ne.NF90_NOERR) then 233 266 write(*,*) "Failed to find albedo in file!" 234 else 235 ierr=NF_GET_VAR_REAL(nid,nvarid,TESalbs) 236 endif 267 write(*,*)trim(nf90_strerror(ierr)) 268 stop 269 else 270 ierr=nf90_get_var(nid,nvarid,TESalbs) 271 if (ierr.ne.NF90_NOERR) then 272 write(*,*) "Failed loading albedo data from file!" 273 write(*,*)trim(nf90_strerror(ierr)) 274 stop 275 endif 276 endif 277 278 ierr=nf90_close(nid) 237 279 238 280 ! constants: -
trunk/LMDZ.MARS/libf/phymars/co2snow.F
r1047 r1130 3 3 4 4 use surfdat_h, only: iceradius, dtemisice 5 use comgeomfi_h, only: lati ! grid point latitudes (rad) 5 6 IMPLICIT NONE 6 7 … … 107 108 c dtemis: Time scale for increasing the ice emissivity 108 109 109 IF( ig.GT.ngrid/2+1) THEN110 icap=2 110 IF(lati(ig).LT. 0.) THEN 111 icap=2 ! Southern hemisphere 111 112 ELSE 112 icap=1 113 icap=1 ! Northern Hemisphere 113 114 ENDIF 114 115 -
trunk/LMDZ.MARS/libf/phymars/comgeomfi_h.F90
r1047 r1130 5 5 6 6 ! These arrays are allocated in inifis 7 REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: long,lati,area 7 REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: long ! longitudes (rad) 8 REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: lati ! latitudes (rad) 9 REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: area ! mesh area (m2) 8 10 REAL,SAVE :: totarea 9 11 -
trunk/LMDZ.MARS/libf/phymars/datareadnc.F
r690 r1130 99 99 100 100 101 #include "lmdstd.h"101 !#include "lmdstd.h" 102 102 #include "fxyprim.h" 103 103 -
trunk/LMDZ.MARS/libf/phymars/eofdump_mod.F90
r1047 r1130 27 27 integer,intent(in) :: ngrid ! total number of physics grid points 28 28 integer,intent(in) :: nlayer ! number of atmospheric layers 29 real *4u(ngrid,nlayer)30 real *4v(ngrid,nlayer)31 real *4t(ngrid,nlayer)32 real *4rho(ngrid,nlayer)33 real *4ps(ngrid)29 real,intent(in) :: u(ngrid,nlayer) 30 real,intent(in) :: v(ngrid,nlayer) 31 real,intent(in) :: t(ngrid,nlayer) 32 real,intent(in) :: rho(ngrid,nlayer) 33 real,intent(in) :: ps(ngrid) 34 34 integer,save :: count=0 35 35 integer i,j,l, ig … … 56 56 do j=1+eofskip/2,jjm+1,eofskip 57 57 ig = 1+ (j-2)*iim +i 58 #ifdef NC_DOUBLE 59 write(uedata) (real(u(ig,l)),l=1,nlayer) 60 write(uedata) (real(v(ig,l)),l=1,nlayer) 61 write(uedata) (real(t(ig,l)),l=1,nlayer) 62 write(uedata) (real(rho(ig,l)),l=1,nlayer) 63 write(uedata) real(ps(ig)) 64 #else 58 65 write(uedata) (u(ig,l),l=1,nlayer) 59 66 write(uedata) (v(ig,l),l=1,nlayer) … … 61 68 write(uedata) (rho(ig,l),l=1,nlayer) 62 69 write(uedata) ps(ig) 70 #endif 63 71 enddo 64 72 enddo … … 112 120 if(j.eq.1) stop 'Problem in ineofdump.F' 113 121 if(j.eq.jjm+1) stop 'Problem in ineofdump.F' 122 #ifdef NC_DOUBLE 123 write(uehead,*) real(long(ig)*180./pi),real(lati(ig)*180./pi) 124 #else 114 125 write(uehead,*) long(ig)*180./pi, lati(ig)*180./pi 126 #endif 115 127 ! write(*,*) 'eof grid j=',j,' lat= ', lati(ig)*180./pi 116 128 enddo 117 129 enddo 118 130 131 #ifdef NC_DOUBLE 132 write(uehead,*) real(aps) 133 write(uehead,*) real(bps) 134 #else 119 135 write(uehead,*) aps 120 136 write(uehead,*) bps 137 #endif 121 138 close(uehead) 122 139 ! -
trunk/LMDZ.MARS/libf/phymars/inifis.F
r1112 r1130 59 59 use yomlw_h, only: ini_yomlw_h 60 60 use conc_mod, only: ini_conc_mod 61 use control_mod, only: ecritphy 61 62 62 63 #ifdef MESOSCALE … … 136 137 ! ENDIF 137 138 139 ! read in 'ecritphy' (frequency of calls to physics, in dynamical steps) 140 ! (also done in dyn3d/defrun_new but not in LMDZ.COMMON) 141 call getin("ecritphy",ecritphy) 142 138 143 ! -------------------------------------------------------------- 139 144 ! Reading the "callphys.def" file controlling some key options -
trunk/LMDZ.MARS/libf/phymars/inistats.F
r690 r1130 1 1 subroutine inistats(ierr) 2 2 3 use mod_phys_lmdz_para, only : is_master 3 4 implicit none 4 5 … … 42 43 pseudoalt(l)=-10.*log(presnivs(l)/preff) 43 44 enddo 45 46 if (is_master) then 47 ! only the master needs do this 44 48 45 49 ierr = NF_CREATE("stats.nc",IOR(NF_CLOBBER,NF_64BIT_OFFSET),nid) … … 110 114 ierr=NF_CLOSE(nid) 111 115 116 endif ! of if (is_master) 112 117 end subroutine inistats 113 118 -
trunk/LMDZ.MARS/libf/phymars/initracer.F
r1047 r1130 2 2 3 3 #ifndef MESOSCALE 4 use infotrac, only: tn om4 use infotrac, only: tname 5 5 #endif 6 6 use tracer_mod … … 81 81 txt=" " 82 82 write(txt,'(a1,i2.2)') 'q',iq 83 if (txt.eq.tn om(iq)) then83 if (txt.eq.tname(iq)) then 84 84 count=count+1 85 85 endif … … 95 95 ! copy tracer names from dynamics 96 96 do iq=1,nq 97 noms(iq)=tn om(iq)97 noms(iq)=tname(iq) 98 98 enddo 99 99 #endif -
trunk/LMDZ.MARS/libf/phymars/mkstat.F90
r38 r1130 10 10 ! Yann W. july 2003 11 11 12 use mod_phys_lmdz_para, only : is_master 12 13 13 14 implicit none … … 36 37 ! Incrementation of count for the last step, which is not done in wstats 37 38 count(istime)=count(istime)+1 39 40 if (is_master) then 41 ! only the master needs do this 38 42 39 43 ierr = NF_OPEN("stats.nc",NF_WRITE,nid) … … 162 166 ierr= NF_CLOSE(nid) 163 167 168 endif ! of if (is_master) 169 164 170 end -
trunk/LMDZ.MARS/libf/phymars/newcondens.F
r1114 r1130 217 217 ENDIF ! of IF (firstcall) 218 218 zcpi=1./cpp 219 219 220 c 220 221 c====================================================================== -
trunk/LMDZ.MARS/libf/phymars/newstart.F
r1087 r1130 17 17 ! to use 'getin' 18 18 use ioipsl_getincom, only: getin 19 use infotrac, only: iniadvtrac, nqtot, tnom 20 use tracer_mod, only: noms, igcm_h2o_vap, igcm_h2o_ice 19 use infotrac, only: iniadvtrac, nqtot, tname 20 use tracer_mod, only: noms, igcm_dust_number, igcm_dust_mass, 21 & igcm_ccn_number, igcm_ccn_mass, 22 & igcm_h2o_vap, igcm_h2o_ice 21 23 use surfdat_h, only: phisfi, z0, zmea, zstd, zsig, zgam, zthe, 22 24 & albedodat, z0_default 23 25 use comsoil_h, only: inertiedat, layer, mlayer, nsoilmx 26 use control_mod, only: day_step, iphysiq, anneeref 27 use phyredem, only: physdem0, physdem1 28 use iostart, only: open_startphy 29 use comgeomphy, only: initcomgeomphy 24 30 implicit none 25 31 … … 36 42 #include "comvert.h" 37 43 #include "comgeom2.h" 38 #include "control.h"44 !#include "control.h" 39 45 #include "logic.h" 40 46 #include "description.h" 41 47 #include "ener.h" 42 48 #include "temps.h" 43 #include "lmdstd.h"49 !#include "lmdstd.h" 44 50 #include "comdissnew.h" 45 51 #include "clesph0.h" … … 142 148 c variables diverses 143 149 c------------------- 144 real choix_1 150 real choix_1 ! ==0 : read start_archive file ; ==1: read start files 145 151 character*80 fichnom 146 152 integer Lmodif,iq … … 183 189 preff = 610. ! for Mars, instead of 101325. (Earth) 184 190 pa= 20 ! for Mars, instead of 500 (Earth) 191 192 ! initialize "serial/parallel" related stuff 193 CALL init_phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/)) 194 call initcomgeomphy 185 195 186 196 ! Load tracer number and names: … … 316 326 c----------------------------------------------------------------------- 317 327 if (choix_1.eq.0) then 328 ! tabfi requires that input file be first opened by open_startphy(fichnom) 329 fichnom = 'start_archive.nc' 330 call open_startphy(fichnom) 318 331 call tabfi (nid,Lmodif,tab0,day_ini,lllm,p_rad, 319 332 . p_omeg,p_g,p_mugaz,p_daysec,time) 320 333 else if (choix_1.eq.1) then 334 fichnom = 'startfi.nc' 335 call open_startphy(fichnom) 321 336 call tabfi (nid_fi,Lmodif,tab0,day_ini,lllm,p_rad, 322 337 . p_omeg,p_g,p_mugaz,p_daysec,time) … … 461 476 txt=" " 462 477 write(txt,'(a1,i2.2)') 'q',iq 463 if (txt.eq.tn om(iq)) then478 if (txt.eq.tname(iq)) then 464 479 count=count+1 465 480 endif … … 471 486 if (count.eq.nqtot) then 472 487 write(*,*) 'Newstart: updating tracer names' 473 ! copy noms(:) to tn om(:) to have matching tracer names in physics488 ! copy noms(:) to tname(:) to have matching tracer names in physics 474 489 ! and dynamics 475 tn om(1:nqtot)=noms(1:nqtot)490 tname(1:nqtot)=noms(1:nqtot) 476 491 endif 477 492 … … 497 512 $ tracer' 498 513 write(*,*) 'q=profile : specify a profile for a tracer' 514 write(*,*) 'freedust : rescale dust to a true value' 499 515 write(*,*) 'ini_q : tracers initialization for chemistry 500 516 $ and water vapour' … … 723 739 write(*,*) 'Which tracer name do you want to change ?' 724 740 do iq=1,nqtot 725 write(*,'(i3,a3,a20)')iq,' : ',trim(tn om(iq))741 write(*,'(i3,a3,a20)')iq,' : ',trim(tname(iq)) 726 742 enddo 727 743 write(*,'(a35,i3)') … … 730 746 read(*,*) iq 731 747 if ((iq.ge.1).and.(iq.le.nqtot)) then 732 write(*,*)'Change tracer name ',trim(tn om(iq)),' to ?'748 write(*,*)'Change tracer name ',trim(tname(iq)),' to ?' 733 749 read(*,*) txt 734 tn om(iq)=txt750 tname(iq)=txt 735 751 write(*,*)'Do you want to change another tracer name (y/n)?' 736 752 read(*,'(a)') yes … … 768 784 write(*,*) 'Which tracer do you want to modify ?' 769 785 do iq=1,nqtot 770 write(*,*)iq,' : ',trim(tn om(iq))786 write(*,*)iq,' : ',trim(tname(iq)) 771 787 enddo 772 788 write(*,*) '(choose between 1 and ',nqtot,')' … … 777 793 cycle 778 794 endif 779 write(*,*)'mixing ratio of tracer ',trim(tn om(iq)),795 write(*,*)'mixing ratio of tracer ',trim(tname(iq)), 780 796 & ' ? (kg/kg)' 781 797 read(*,*) val … … 787 803 ENDDO 788 804 ENDDO 789 write(*,*) 'SURFACE value of tracer ',trim(tn om(iq)),805 write(*,*) 'SURFACE value of tracer ',trim(tname(iq)), 790 806 & ' ? (kg/m2)' 791 807 read(*,*) val … … 804 820 write(*,*) 'Which tracer do you want to set?' 805 821 do iq=1,nqtot 806 write(*,*)iq,' : ',trim(tn om(iq))822 write(*,*)iq,' : ',trim(tname(iq)) 807 823 enddo 808 824 write(*,*) '(choose between 1 and ',nqtot,')' … … 814 830 endif 815 831 ! look for input file 'profile_tracer' 816 txt="profile_"//trim(tn om(iq))832 txt="profile_"//trim(tname(iq)) 817 833 open(41,file=trim(txt),status='old',form='formatted', 818 834 & iostat=ierr) … … 831 847 q(:,:,l,iq)=profile(l+1) 832 848 enddo 833 write(*,*)'OK, tracer ',trim(tn om(iq)),' initialized ',834 & 849 write(*,*)'OK, tracer ',trim(tname(iq)), 850 & ' initialized ','using values from file ',trim(txt) 835 851 else 836 852 write(*,*)'problem reading file ',trim(txt),' !' 837 write(*,*)'No modifications to tracer ',trim(tn om(iq))853 write(*,*)'No modifications to tracer ',trim(tname(iq)) 838 854 endif 839 855 else 840 856 write(*,*)'Could not find file ',trim(txt),' !' 841 write(*,*)'No modifications to tracer ',trim(tn om(iq))857 write(*,*)'No modifications to tracer ',trim(tname(iq)) 842 858 endif 843 859 860 c q=profile : initialize tracer with a given profile 861 c -------------------------------------------------- 862 else if (trim(modif) .eq. 'freedust') then 863 do l=1,llm 864 do j=1,jjp1 865 do i=1,iip1 866 if (igcm_dust_number .ne. 0) 867 & q(i,j,l,igcm_dust_number)= 868 & q(i,j,l,igcm_dust_number) * 1e-3 ! grosso modo 869 if (igcm_dust_mass .ne. 0) 870 & q(i,j,l,igcm_dust_mass)= 871 & q(i,j,l,igcm_dust_mass) * 1e-3 ! grosso modo 872 if (igcm_ccn_number .ne. 0) 873 & q(i,j,l,igcm_ccn_number)= 874 & q(i,j,l,igcm_ccn_number) * 1e-3 ! grosso modo 875 if (igcm_ccn_mass .ne. 0) 876 & q(i,j,l,igcm_ccn_mass)= 877 & q(i,j,l,igcm_ccn_mass) * 1e-3 ! grosso modo 878 end do 879 end do 880 end do 881 882 ! We want to have the very same value at lon -180 and lon 180 883 do l = 1,llm 884 do j = 1,jjp1 885 do iq = 1,nqtot 886 q(iip1,j,l,iq) = q(1,j,l,iq) 887 end do 888 end do 889 end do 844 890 845 891 c ini_q : Initialize tracers for chemistry -
trunk/LMDZ.MARS/libf/phymars/physiq.F
r1124 r1130 28 28 use slope_mod, only: theta_sl, psi_sl 29 29 use conc_mod, only: rnew, cpnew, mmean 30 use control_mod, only: iphysiq, day_step, ecritstart 31 use phyredem, only: physdem0, physdem1 30 32 31 33 #ifdef MESOSCALE … … 144 146 #include "planete.h" 145 147 !#include "comsaison.h" 146 #include "control.h"148 !#include "control.h" 147 149 !#include "dimradmars.h" 148 150 ! naerkind is set in scatterers.h (built when compiling with makegcm -s #) … … 515 517 #ifndef MESOSCALE 516 518 if (callslope) call getslopes(ngrid,phisfi) 517 519 520 if (ngrid.ne.1) then ! no need to create a restart file in 1d 518 521 call physdem0("restartfi.nc",long,lati,nsoilmx,ngrid,nlayer,nq, 519 522 . ptimestep,pday,time_phys,area, 520 523 . albedodat,inertiedat,zmea,zstd,zsig,zgam,zthe) 521 524 endif 522 525 #endif 523 526 … … 676 679 c Radiative transfer 677 680 c ------------------ 678 679 681 CALL callradite(icount,ngrid,nlayer,nq,zday,zls,pq,albedo, 680 682 $ emis,mu0,zplev,zplay,pt,tsurf,fract,dist_sol,igout, … … 1036 1038 & nq,tau,tauscaling,rdust,rice,nuice, 1037 1039 & rsedcloud,rhocloud) 1038 1040 1039 1041 c Temperature variation due to latent heat release 1040 1042 if (activice) then … … 1135 1137 c ------------- 1136 1138 IF (sedimentation) THEN 1137 !call zerophys(ngrid*nlayer*nq, zdqsed)1138 1139 zdqsed(1:ngrid,1:nlayer,1:nq)=0 1139 !call zerophys(ngrid*nq, zdqssed)1140 1140 zdqssed(1:ngrid,1:nq)=0 1141 1141 … … 2073 2073 & 'Mean reff', 2074 2074 & 'm',2,rave) 2075 CALL WRITEDIAGFI(ngrid,"Nccntot", 2075 if (scavenging) then 2076 CALL WRITEDIAGFI(ngrid,"Nccntot", 2076 2077 & "condensation nuclei","Nbr/m2", 2077 2078 & 2,Nccntot) 2078 CALL WRITEDIAGFI(ngrid,"Mccntot",2079 CALL WRITEDIAGFI(ngrid,"Mccntot", 2079 2080 & "mass condensation nuclei","kg/m2", 2080 2081 & 2,Mccntot) 2082 endif 2081 2083 call WRITEDIAGFI(ngrid,'rice','Ice particle size', 2082 2084 & 'm',3,rice) -
trunk/LMDZ.MARS/libf/phymars/planete.h
r224 r1130 1 c-----------------------------------------------------------------------2 cINCLUDE planet.h1 !----------------------------------------------------------------------- 2 ! INCLUDE planet.h 3 3 4 4 COMMON/planet/aphelie,periheli,year_day,peri_day, & … … 12 12 & timeperi,e_elips,p_elips,unitastr 13 13 14 c-----------------------------------------------------------------------14 !----------------------------------------------------------------------- -
trunk/LMDZ.MARS/libf/phymars/soil_settings.F
r1047 r1130 1 1 subroutine soil_settings(nid,ngrid,nsoil,tsurf,tsoil,indextime) 2 2 3 use netcdf3 ! use netcdf 4 4 use comsoil_h, only: layer, mlayer, inertiedat, volcapa 5 use iostart, only: inquire_field_ndims, get_var, get_field, 6 & inquire_field, inquire_dimension_length 5 7 implicit none 6 8 … … 74 76 real,parameter :: default_volcapa=1.e6 75 77 78 logical :: found,ok 79 76 80 !====================================================================== 77 81 … … 81 85 ! 1.1 Start by reading how many layers of soil there are 82 86 83 ierr=nf90_inq_dimid(nid,"subsurface_layers",dimid) 84 if (ierr.ne.nf90_noerr) then 85 write(*,*)'soil_settings: Problem reading <subsurface_layers>' 86 write(*,*)trim(nf90_strerror(ierr)) 87 call abort 88 endif 89 90 ierr=nf90_inquire_dimension(nid,dimid,len=dimlen) 91 if (ierr.ne.nf90_noerr) then 92 write(*,*)'soil_settings: Problem getting <subsurface_layers>', 93 & 'length' 94 write(*,*)trim(nf90_strerror(ierr)) 95 call abort 96 endif 87 ! ierr=nf90_inq_dimid(nid,"subsurface_layers",dimid) 88 ! if (ierr.ne.nf90_noerr) then 89 ! write(*,*)'soil_settings: Problem reading <subsurface_layers>' 90 ! write(*,*)trim(nf90_strerror(ierr)) 91 ! call abort 92 ! endif 93 94 ! ierr=nf90_inquire_dimension(nid,dimid,len=dimlen) 95 ! if (ierr.ne.nf90_noerr) then 96 ! write(*,*)'soil_settings: Problem getting <subsurface_layers>', 97 ! & 'length' 98 ! write(*,*)trim(nf90_strerror(ierr)) 99 ! call abort 100 ! endif 101 dimlen=inquire_dimension_length("subsurface_layers") 97 102 98 103 if (dimlen.ne.nsoil) then … … 107 112 ! (in ye old days, thermal inertia was only given at the "surface") 108 113 ! Look for thermal inertia data 109 ierr=nf90_inq_varid(nid,"inertiedat",nvarid) 110 if (ierr.NE.nf90_noerr) then 111 write(*,*)'soil_settings: Field <inertiedat> not found!' 112 write(*,*)trim(nf90_strerror(ierr)) 113 call abort 114 endif 115 116 ! Read the # of dimensions <inertidat> was defined as using 117 ierr=nf90_inquire_variable(nid,nvarid,ndims=ndims) 118 ! if (ndims.eq.1) then we have the "old 2D-surface" format 114 ! ierr=nf90_inq_varid(nid,"inertiedat",nvarid) 115 ! if (ierr.NE.nf90_noerr) then 116 ! write(*,*)'soil_settings: Field <inertiedat> not found!' 117 ! write(*,*)trim(nf90_strerror(ierr)) 118 ! call abort 119 ! endif 120 ! 121 ! ! Read the # of dimensions <inertidat> was defined as using 122 ! ierr=nf90_inquire_variable(nid,nvarid,ndims=ndims) 123 ! ! if (ndims.eq.1) then we have the "old 2D-surface" format 124 ndims=inquire_field_ndims("inertiedat") 119 125 120 126 ! 1.3 Read depths values or set olddepthdef flag and values … … 136 142 enddo 137 143 else ! Look for depth 138 ierr=nf90_inq_varid(nid,"soildepth",nvarid)139 if (ierr.ne.nf90_noerr) then140 write(*,*)'soil_settings: Field <soildepth> not found!'141 write(*,*)trim(nf90_strerror(ierr))142 call abort143 endif144 ! ierr=nf90_inq_varid(nid,"soildepth",nvarid) 145 ! if (ierr.ne.nf90_noerr) then 146 ! write(*,*)'soil_settings: Field <soildepth> not found!' 147 ! write(*,*)trim(nf90_strerror(ierr)) 148 ! call abort 149 ! endif 144 150 ! read <depth> coordinate 145 151 if (interpol) then !put values in oldmlayer 146 ierr=nf90_get_var(nid,nvarid,oldmlayer) 147 if (ierr.ne.nf90_noerr) then 148 write(*,*)'soil_settings: Problem while reading <soildepth>' 149 write(*,*)trim(nf90_strerror(ierr)) 150 call abort 152 ! ierr=nf90_get_var(nid,nvarid,oldmlayer) 153 ! if (ierr.ne.nf90_noerr) then 154 ! write(*,*)'soil_settings: Problem while reading <soildepth>' 155 ! write(*,*)trim(nf90_strerror(ierr)) 156 ! call abort 157 ! endif 158 call get_var("soildepth",oldmlayer,found) 159 if (.not.found) then 160 write(*,*)'soil_settings: Problem while reading <soildepth>' 151 161 endif 152 162 else ! put values in mlayer 153 ierr=nf90_get_var(nid,nvarid,mlayer) 154 if (ierr.ne.nf90_noerr) then 155 write(*,*)'soil_settings: Problem while reading <soildepth>' 156 write(*,*)trim(nf90_strerror(ierr)) 157 call abort 163 ! ierr=nf90_get_var(nid,nvarid,mlayer) 164 ! if (ierr.ne.nf90_noerr) then 165 ! write(*,*)'soil_settings: Problem while reading <soildepth>' 166 ! write(*,*)trim(nf90_strerror(ierr)) 167 ! call abort 168 ! endif 169 call get_var("soildepth",mlayer,found) 170 if (.not.found) then 171 write(*,*)'soil_settings: Problem while reading <soildepth>' 158 172 endif 159 173 endif !of if (interpol) … … 217 231 218 232 ! 3.1 Look (again) for thermal inertia data (to reset nvarid) 219 ierr=nf90_inq_varid(nid,"inertiedat",nvarid)220 if (ierr.NE.nf90_noerr) then221 write(*,*)'soil_settings: Field <inertiedat> not found!'222 write(*,*)trim(nf90_strerror(ierr))223 call abort224 endif233 ! ierr=nf90_inq_varid(nid,"inertiedat",nvarid) 234 ! if (ierr.NE.nf90_noerr) then 235 ! write(*,*)'soil_settings: Field <inertiedat> not found!' 236 ! write(*,*)trim(nf90_strerror(ierr)) 237 ! call abort 238 ! endif 225 239 226 240 ! 3.2 Knowing the # of dimensions <inertidat> was defined as using, … … 232 246 ! Read Surface thermal inertia 233 247 allocate(surfinertia(ngrid)) 234 ierr=nf90_get_var(nid,nvarid,surfinertia) 235 if (ierr.NE.nf90_noerr) then 236 write(*,*)'soil_settings: Problem while reading <inertiedat>' 237 write(*,*)trim(nf90_strerror(ierr)) 248 ! ierr=nf90_get_var(nid,nvarid,surfinertia) 249 ! if (ierr.NE.nf90_noerr) then 250 ! write(*,*)'soil_settings: Problem while reading <inertiedat>' 251 ! write(*,*)trim(nf90_strerror(ierr)) 252 ! call abort 253 ! endif 254 call get_field("inertiedat",surfinertia,found) 255 if (.not.found) then 256 write(*,*) "soil_settings: Failed loading <inertiedat>" 238 257 call abort 239 258 endif 240 259 241 260 write(*,*)' => Building soil thermal inertia (using reference sur … … 255 274 stop 256 275 endif 257 endif 258 ierr=nf90_get_var(nid,nvarid,oldinertiedat) 259 if (ierr.NE.nf90_noerr) then 260 write(*,*)'soil_settings: Problem while reading <inertiedat>' 261 write(*,*)trim(nf90_strerror(ierr)) 262 call abort 276 endif ! of if (.not.allocated(oldinertiedat)) 277 ! ierr=nf90_get_var(nid,nvarid,oldinertiedat) 278 ! if (ierr.NE.nf90_noerr) then 279 ! write(*,*)'soil_settings: Problem while reading <inertiedat>' 280 ! write(*,*)trim(nf90_strerror(ierr)) 281 ! call abort 282 ! endif 283 call get_field("inertiedat",oldinertiedat,found) 284 if (.not.found) then 285 write(*,*) "soil_settings: Failed loading <inertiedat>" 286 call abort 263 287 endif 264 288 else ! put values in therm_i 265 ierr=nf90_get_var(nid,nvarid,inertiedat) 266 if (ierr.NE.nf90_noerr) then 267 write(*,*)'soil_settings: Problem while reading <inertiedat>' 268 write(*,*)trim(nf90_strerror(ierr)) 269 call abort 270 endif 289 ! ierr=nf90_get_var(nid,nvarid,inertiedat) 290 ! if (ierr.NE.nf90_noerr) then 291 ! write(*,*)'soil_settings: Problem while reading <inertiedat>' 292 ! write(*,*)trim(nf90_strerror(ierr)) 293 ! call abort 294 call get_field("inertiedat",inertiedat,found) 295 if (.not.found) then 296 write(*,*) "soil_settings: Failed loading <inertiedat>" 297 call abort 298 endif 299 ! endif 271 300 endif ! of if (interpol) 272 301 endif ! of if (ndims.eq.1) … … 275 304 ! ------------------------- 276 305 277 ierr=nf90_inq_varid(nid,"tsoil",nvarid) 278 if (ierr.ne.nf90_noerr) then 306 ! ierr=nf90_inq_varid(nid,"tsoil",nvarid) 307 ok=inquire_field("tsoil") 308 ! if (ierr.ne.nf90_noerr) then 309 if (.not.ok) then 279 310 write(*,*)'soil_settings: Field <tsoil> not found!' 280 311 write(*,*)' => Building <tsoil> from surface values <tsurf>' … … 292 323 endif 293 324 endif 294 ierr=nf90_get_var(nid,nvarid,oldtsoil) 295 if (ierr.ne.nf90_noerr) then 296 write(*,*)'soil_settings: Problem while reading <tsoil>' 297 write(*,*)trim(nf90_strerror(ierr)) 298 call abort 299 endif 325 ! ierr=nf90_get_var(nid,nvarid,oldtsoil) 326 ! if (ierr.ne.nf90_noerr) then 327 ! write(*,*)'soil_settings: Problem while reading <tsoil>' 328 ! write(*,*)trim(nf90_strerror(ierr)) 329 ! call abort 330 ! endif 331 call get_field("tsoil",oldtsoil,found) 332 if (.not.found) then 333 write(*,*) "soil_settings: Failed loading <tsoil>" 334 call abort 335 endif 300 336 else ! put values in tsoil 301 corner(1)=1 302 corner(2)=1 303 corner(3)=indextime 304 edges(1)=ngrid 305 edges(2)=nsoil 306 edges(3)=1 307 !ierr=nf90_get_var(nid,nvarid,tsoil,corner,edges) 308 ierr=nf90_get_var(nid,nvarid,tsoil) 309 if (ierr.ne.nf90_noerr) then 310 write(*,*)'soil_settings: Problem while reading <tsoil>' 311 write(*,*)trim(nf90_strerror(ierr)) 312 call abort 313 endif 337 ! corner(1)=1 338 ! corner(2)=1 339 ! corner(3)=indextime 340 ! edges(1)=ngrid 341 ! edges(2)=nsoil 342 ! edges(3)=1 343 ! !ierr=nf90_get_var(nid,nvarid,tsoil,corner,edges) 344 ! ierr=nf90_get_var(nid,nvarid,tsoil) 345 ! if (ierr.ne.nf90_noerr) then 346 ! write(*,*)'soil_settings: Problem while reading <tsoil>' 347 ! write(*,*)trim(nf90_strerror(ierr)) 348 ! call abort 349 ! endif 350 call get_field("tsoil",tsoil,found,timeindex=indextime) 351 if (.not.found) then 352 write(*,*) "soil_settings: Failed loading <tsoil>" 353 call abort 354 endif 314 355 endif ! of if (interpol) 315 endif 356 endif! of if (.not.ok) 316 357 317 358 ! 5. If necessary, interpolate soil temperatures and thermal inertias -
trunk/LMDZ.MARS/libf/phymars/start2archive.F
r1087 r1130 19 19 c======================================================================= 20 20 21 use infotrac, only: iniadvtrac, nqtot, tn om21 use infotrac, only: iniadvtrac, nqtot, tname 22 22 use comsoil_h, only: nsoilmx, inertiedat 23 23 use surfdat_h, only: ini_surfdat_h 24 24 use comsoil_h, only: ini_comsoil_h 25 use comgeomphy, only: initcomgeomphy 25 26 implicit none 26 27 … … 34 35 #include "logic.h" 35 36 #include "temps.h" 36 #include "control.h"37 !#include "control.h" 37 38 #include "ener.h" 38 39 #include "description.h" … … 119 120 CALL defrun_new(99, .TRUE. ) 120 121 grireg = .TRUE. 122 ! initialize "serial/parallel" related stuff 123 CALL init_phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/)) 124 call initcomgeomphy 121 125 122 126 c======================================================================= … … 355 359 c call write_archive(nid,ntime,'q'//str2,'tracer','kg/kg', 356 360 c . 3,q(1,1,iq)) 357 call write_archive(nid,ntime,tn om(iq),'tracer','kg/kg',361 call write_archive(nid,ntime,tname(iq),'tracer','kg/kg', 358 362 & 3,q(1,1,iq)) 359 363 end do … … 365 369 c call write_archive(nid,ntime,'qsurf'//str2,'Tracer on surface', 366 370 c $ 'kg.m-2',2,qsurfS(1,iq)) 367 txt=trim(tn om(iq))//"_surf"371 txt=trim(tname(iq))//"_surf" 368 372 call write_archive(nid,ntime,txt,'Tracer on surface', 369 373 & 'kg.m-2',2,qsurfS(1,iq)) … … 404 408 c----------------------------------------------------------------------- 405 409 410 write(*,*) "startarchive: all is well that ends well" 411 406 412 end -
trunk/LMDZ.MARS/libf/phymars/surfini.F
r1087 r1130 8 8 & albedo_h2o_ice, inert_h2o_ice, albedodat, 9 9 & albedice 10 use mod_grid_phy_lmdz, only : klon_glo ! # of physics point on full grid 11 use mod_phys_lmdz_para, only : is_master, gather, scatter 10 12 IMPLICIT NONE 11 13 c======================================================================= … … 27 29 #include "datafile.h" 28 30 29 INTEGER ngrid,ig,icap,iq,alternate 30 REAL piceco2(ngrid),psolaralb(ngrid,2) 31 REAL qsurf(ngrid,nqmx) !tracer on surface (kg/m2) 31 integer,intent(in) :: ngrid ! number of atmospheric columns 32 real,intent(in) :: piceco2(ngrid) ! CO2 ice thickness 33 real,intent(inout) :: qsurf(ngrid,nqmx) ! tracer on surface (kg/m2) 34 real,intent(out) :: psolaralb(ngrid,2) ! albedo 35 36 INTEGER ig,icap,iq,alternate 32 37 REAL icedryness ! ice dryness 33 38 34 39 ! longwatercaptag is watercaptag. Trick for some compilers 35 40 LOGICAL, DIMENSION(100000) :: longwatercaptag 36 37 EXTERNAL ISMIN,ISMAX38 INTEGER ISMIN,ISMAX39 41 40 42 ! There are 3 different modes for ice distribution: … … 53 55 REAL zelat,zelon 54 56 57 #ifdef CPP_PARA 55 58 INTEGER nb_ice(ngrid,2) ! number of counts | detected ice for GCM grid 59 #else 60 INTEGER nb_ice(klon_glo,2) 61 #endif 56 62 INTEGER latice(jjm,2),lonice (iim,2) ! number of counts | detected ice along lat & lon axis 57 63 … … 64 70 65 71 character (len=100) :: zedatafile 72 73 ! to handle parallel cases 74 #if CPP_PARA 75 logical watercaptag_glo(klon_glo) 76 real dryness_glo(klon_glo) 77 real lati_glo(klon_glo) 78 real long_glo(klon_glo) 79 #else 80 logical watercaptag_glo(ngrid) 81 real dryness_glo(ngrid) 82 real lati_glo(ngrid) 83 real long_glo(ngrid) 84 #endif 85 66 86 c 67 87 c======================================================================= 88 ! Initialize watercaptag (default is false) 89 watercaptag_glo(:)=.false. 68 90 69 91 c water ice outliers … … 93 115 endif 94 116 95 write(*,*) " Ice dryness ?"117 write(*,*) "surfini: Ice dryness ?" 96 118 icedryness=1. ! default value 97 119 call getin("icedryness",icedryness) 98 write(*,*) " icedryness = ",icedryness120 write(*,*) "surfini: icedryness = ",icedryness 99 121 dryness (:) = icedryness 100 122 … … 125 147 #else 126 148 127 128 129 IF (ngrid .eq. 1) THEN ! special case for 1d --> do nothing 149 ! To be able to run in parallel, we work on the full grid 150 ! and dispatch results afterwards 151 152 ! start by geting latitudes and logitudes on full grid 153 ! (in serial mode, this is just a copy) 154 call gather(lati,lati_glo) 155 call gather(long,long_glo) 156 157 if (is_master) then 158 159 IF (ngrid .eq. 1) THEN ! special case for 1d --> do nothing 130 160 131 161 print*, 'ngrid = 1, do no put ice caps in surfini.F' 132 162 133 ELSE IF (icelocationmode .eq. 1) THEN163 ELSE IF (icelocationmode .eq. 1) THEN 134 164 135 165 print*,'Surfini: ice caps defined from surface.nc' … … 144 174 145 175 146 zedatafile = trim(datafile)176 zedatafile = trim(datafile) 147 177 148 178 149 ierr=nf90_open(trim(zedatafile)//'/surface.nc',150 & NF90_NOWRITE,nid)179 ierr=nf90_open(trim(zedatafile)//'/surface.nc', 180 & NF90_NOWRITE,nid) 151 181 152 IF (ierr.NE.nf90_noerr) THEN182 IF (ierr.NE.nf90_noerr) THEN 153 183 write(*,*)'Error : cannot open file surface.nc ' 154 184 write(*,*)'(in phymars/surfini.F)' … … 160 190 write(*,*)' http://www.lmd.jussieu.fr/~forget/datagcm/datafile' 161 191 CALL ABORT 162 ENDIF163 164 165 ierr=nf90_inq_varid(nid, string, nvarid)166 if (ierr.ne.nf90_noerr) then167 write(*,*) 'surfini error, cannot find ',trim(string)168 write(*,*) ' in file ',trim(zedatafile),'/surface.nc'169 write(*,*)trim(nf90_strerror(ierr))170 stop171 endif172 173 ierr=nf90_get_var(nid, nvarid, zdata)174 175 if (ierr.ne.nf90_noerr) then176 write(*,*) 'surfini: error failed loading ',trim(string)177 write(*,*)trim(nf90_strerror(ierr))178 stop179 endif192 ENDIF 193 194 195 ierr=nf90_inq_varid(nid, string, nvarid) 196 if (ierr.ne.nf90_noerr) then 197 write(*,*) 'surfini error, cannot find ',trim(string) 198 write(*,*) ' in file ',trim(zedatafile),'/surface.nc' 199 write(*,*)trim(nf90_strerror(ierr)) 200 stop 201 endif 202 203 ierr=nf90_get_var(nid, nvarid, zdata) 204 205 if (ierr.ne.nf90_noerr) then 206 write(*,*) 'surfini: error failed loading ',trim(string) 207 write(*,*)trim(nf90_strerror(ierr)) 208 stop 209 endif 180 210 181 211 182 ierr=nf90_close(nid)212 ierr=nf90_close(nid) 183 213 184 214 185 nb_ice(:,1) = 1 ! default: there is no ice186 latice(:,1) = 1187 lonice(:,1) = 1188 nb_ice(:,2) = 0189 latice(:,2) = 0190 lonice(:,2) = 0191 !print*,'jjm,iim',jjm,iim ! jjm = nb lati , iim = nb longi192 193 ! loop over the GCM grid - except for poles (ig=1 and ngrid)194 do ig=2,ngrid-1195 196 ! loop over the surface file grid197 do i=1,imd198 do j=1,jmd199 zelon = i - 180.200 zelat = 90. - j201 if ((abs(lati (ig)*180./pi-zelat) .le.90./real(jjm)) .and.202 & (abs(long (ig)*180./pi-zelon) .le.180./real(iim))) then215 nb_ice(:,1) = 1 ! default: there is no ice 216 latice(:,1) = 1 217 lonice(:,1) = 1 218 nb_ice(:,2) = 0 219 latice(:,2) = 0 220 lonice(:,2) = 0 221 !print*,'jjm,iim',jjm,iim ! jjm = nb lati , iim = nb longi 222 223 ! loop over the GCM grid - except for poles (ig=1 and ngrid) 224 do ig=2,klon_glo-1 225 226 ! loop over the surface file grid 227 do i=1,imd 228 do j=1,jmd 229 zelon = i - 180. 230 zelat = 90. - j 231 if ((abs(lati_glo(ig)*180./pi-zelat).le.90./real(jjm)) .and. 232 & (abs(long_glo(ig)*180./pi-zelon).le.180./real(iim))) then 203 233 ! count all points in that GCM grid point 204 234 nb_ice(ig,1) = nb_ice(ig,1) + 1 … … 207 237 & nb_ice(ig,2) = nb_ice(ig,2) + 1 208 238 endif 209 enddo210 enddo239 enddo 240 enddo 211 241 212 242 ! projection of nb_ice on GCM lat and lon axes 213 latice(1+(ig-2)/iim,:) =243 latice(1+(ig-2)/iim,:) = 214 244 & latice(1+(ig-2)/iim,:) + nb_ice(ig,:) 215 lonice(1+mod(ig-2,iim),:) =245 lonice(1+mod(ig-2,iim),:) = 216 246 & lonice(1+mod(ig-2,iim),:) + nb_ice(ig,:) ! lonice is USELESS ... 217 247 218 enddo ! of do ig=2,ngrid-1248 enddo ! of do ig=2,klon_glo-1 219 249 220 250 221 251 222 ! special case for poles223 nb_ice(1,2) = 1 ! ice prescribed on north pole224 latice(1,:) = nb_ice(1,:)225 lonice(1,:) = nb_ice(1,:)226 latice(jjm,:) = nb_ice(ngrid,:)227 lonice(iim,:) = nb_ice(ngrid,:)252 ! special case for poles 253 nb_ice(1,2) = 1 ! ice prescribed on north pole 254 latice(1,:) = nb_ice(1,:) 255 lonice(1,:) = nb_ice(1,:) 256 latice(jjm,:) = nb_ice(ngrid,:) 257 lonice(iim,:) = nb_ice(ngrid,:) 228 258 229 259 … … 241 271 242 272 243 ! loop over GCM latitudes. CONSIDER ONLY NORTHERN HEMISPHERE244 do i=1,jjm/2245 step = 1. ! threshold to add ice cap246 count = 0. ! number of ice GCM caps at this latitude247 ! ratiolat is the ratio of area covered by ice within this GCM latitude range248 ratiolat = real(latice(i,2))/real(latice(i,1))249 !print*,'i',i,(i-1)*iim+2,i*iim+1273 ! loop over GCM latitudes. CONSIDER ONLY NORTHERN HEMISPHERE 274 do i=1,jjm/2 275 step = 1. ! threshold to add ice cap 276 count = 0. ! number of ice GCM caps at this latitude 277 ! ratiolat is the ratio of area covered by ice within this GCM latitude range 278 ratiolat = real(latice(i,2))/real(latice(i,1)) 279 !print*,'i',i,(i-1)*iim+2,i*iim+1 250 280 251 ! put ice caps while there is not enough ice,252 ! as long as the threshold is above 20%253 do while ( (count .le. ratiolat*iim ) .and. (step .ge. 0.2))254 count = 0.255 ! loop over GCM longitudes256 do j=1,iim281 ! put ice caps while there is not enough ice, 282 ! as long as the threshold is above 20% 283 do while ( (count .le. ratiolat*iim ) .and. (step .ge. 0.2)) 284 count = 0. 285 ! loop over GCM longitudes 286 do j=1,iim 257 287 ! if the detected ice ratio in the GCM grid point 258 288 ! is more than 'step', then add ice 259 289 if (real(nb_ice((i-1)*iim+1+j,2)) 260 290 & / real(nb_ice((i-1)*iim+1+j,1)) .ge. step) then 261 watercaptag ((i-1)*iim+1+j) = .true.291 watercaptag_glo((i-1)*iim+1+j) = .true. 262 292 count = count + 1 263 293 endif 264 enddo ! of do j=1,iim 294 enddo ! of do j=1,iim 295 !print*, 'step',step,count,ratiolat*iim 296 step = step - 0.01 297 enddo ! of do while 265 298 !print*, 'step',step,count,ratiolat*iim 266 step = step - 0.01 267 enddo ! of do while 268 !print*, 'step',step,count,ratiolat*iim 269 270 enddo ! of do i=1,jjm/2 299 300 enddo ! of do i=1,jjm/2 271 301 272 302 273 ELSE IF (icelocationmode .eq. 2) THEN274 275 print*,'Surfini: predefined ice caps'276 277 if ((iim .eq. 32) .and. (jjm .eq. 24)) then ! 32x24303 ELSE IF (icelocationmode .eq. 2) THEN 304 305 print*,'Surfini: predefined ice caps' 306 307 if ((iim .eq. 32) .and. (jjm .eq. 24)) then ! 32x24 278 308 279 309 print*,'water ice caps distribution for 32x24 resolution' … … 288 318 !--------------------- OUTLIERS ---------------------------- 289 319 290 else if ((iim .eq. 64) .and. (jjm .eq. 48)) then ! 64x48320 else if ((iim .eq. 64) .and. (jjm .eq. 48)) then ! 64x48 291 321 292 322 print*,'water ice caps distribution for 64x48 resolution' … … 323 353 324 354 325 else if (ngrid.ne. 1) then355 else if (klon_glo .ne. 1) then 326 356 327 print*,'No predefined ice location for this resolution :',iim,jjm 328 print*,'Please change icelocationmode in surfini.F' 329 print*,'Or add some new definitions ...' 330 call abort 357 print*,'No predefined ice location for this resolution :', 358 & iim,jjm 359 print*,'Please change icelocationmode in surfini.F' 360 print*,'Or add some new definitions ...' 361 call abort 331 362 332 endif333 334 do ig=1,ngrid335 if (longwatercaptag(ig)) watercaptag (ig) = .true.336 enddo337 338 339 ELSE IF (icelocationmode .eq. 3) THEN340 341 print*,'Surfini: ice caps defined by lat and lon values'342 343 do ig=1, ngrid363 endif 364 365 do ig=1,klon_glo 366 if (longwatercaptag(ig)) watercaptag_glo(ig) = .true. 367 enddo 368 369 370 ELSE IF (icelocationmode .eq. 3) THEN 371 372 print*,'Surfini: ice caps defined by lat and lon values' 373 374 do ig=1,klon_glo 344 375 345 376 c-------- Towards olympia planitia water caps ----------- 346 377 c-------------------------------------------------------- 347 378 348 if ( ( ( lati(ig)*180./pi .ge. 77. ) .and. ! cap #2349 . ( lati (ig)*180./pi .le. 80. ) .and.350 . ( long (ig)*180./pi .ge. 110. ) .and.351 . ( long (ig)*180./pi .le. 181. ) )379 if ( ( ( lati_glo(ig)*180./pi .ge. 77. ) .and. ! cap #2 380 . ( lati_glo(ig)*180./pi .le. 80. ) .and. 381 . ( long_glo(ig)*180./pi .ge. 110. ) .and. 382 . ( long_glo(ig)*180./pi .le. 181. ) ) 352 383 . .or. 353 384 354 . ( ( lati (ig)*180./pi .ge. 75. ) .and. ! cap #4 (Korolev crater)355 . ( lati (ig)*180./pi .le. 76. ) .and.356 . ( long (ig)*180./pi .ge. 150. ) .and.357 . ( long (ig)*180./pi .le. 168. ) )385 . ( ( lati_glo(ig)*180./pi .ge. 75. ) .and. ! cap #4 (Korolev crater) 386 . ( lati_glo(ig)*180./pi .le. 76. ) .and. 387 . ( long_glo(ig)*180./pi .ge. 150. ) .and. 388 . ( long_glo(ig)*180./pi .le. 168. ) ) 358 389 . .or. 359 . ( ( lati (ig)*180./pi .ge. 77 ) .and. ! cap #5360 . ( lati (ig)*180./pi .le. 80. ) .and.361 . ( long (ig)*180./pi .ge. -150.) .and.362 . ( long (ig)*180./pi .le. -110.) ) )390 . ( ( lati_glo(ig)*180./pi .ge. 77 ) .and. ! cap #5 391 . ( lati_glo(ig)*180./pi .le. 80. ) .and. 392 . ( long_glo(ig)*180./pi .ge. -150.) .and. 393 . ( long_glo(ig)*180./pi .le. -110.) ) ) 363 394 . then 364 395 … … 370 401 endif !end if alternate = 0 371 402 372 endif403 endif 373 404 374 405 c----------- Opposite olympia planitia water cap -------- 375 406 c-------------------------------------------------------- 376 407 377 if ( ( ( lati(ig)*180./pi .ge. 80 ) .and.378 . ( lati (ig)*180./pi .le. 84 ) )408 if ( ( ( lati_glo(ig)*180./pi .ge. 80 ) .and. 409 . ( lati_glo(ig)*180./pi .le. 84 ) ) 379 410 . .and. 380 . ( ( long (ig)*180./pi .lt. -95. ) .or. !!! 32x24381 . ( long (ig)*180./pi .gt. 85. ) ) ) then !!! 32x24382 ! . ( ( ( long (ig)*180./pi .ge. -29. ) .and. !!! 64x48383 ! . ( long (ig)*180./pi .le. 90. ) ) .or. !!! 64x48384 ! . ( ( long (ig)*180./pi .ge. -77. ) .and. !!! 64x48385 ! . ( long (ig)*180./pi .le. -70. ) ) ) ) then !!! 64x48386 ! watercaptag (ig)=.true.387 endif411 . ( ( long_glo(ig)*180./pi .lt. -95. ) .or. !!! 32x24 412 . ( long_glo(ig)*180./pi .gt. 85. ) ) ) then !!! 32x24 413 ! . ( ( ( long_glo(ig)*180./pi .ge. -29. ) .and. !!! 64x48 414 ! . ( long_glo(ig)*180./pi .le. 90. ) ) .or. !!! 64x48 415 ! . ( ( long_glo(ig)*180./pi .ge. -77. ) .and. !!! 64x48 416 ! . ( long_glo(ig)*180./pi .le. -70. ) ) ) ) then !!! 64x48 417 ! watercaptag_glo(ig)=.true. 418 endif 388 419 389 420 … … 391 422 c-------------------------------------------------------- 392 423 393 if (abs(lati(ig)*180./pi).gt.80)394 . watercaptag(ig)=.true.424 if (abs(lati_glo(ig)*180./pi).gt.80) 425 . watercaptag_glo(ig)=.true. 395 426 396 427 c-------------------------------------------------------- 397 428 c-------------------------------------------------------- 398 end do ! of (ngrid)399 400 401 ELSE429 end do ! of (klon_glo) 430 431 432 ELSE 402 433 403 434 print*, 'In surfini.F, icelocationmode is ', icelocationmode … … 405 436 call abort 406 437 407 ENDIF ! of if (icelocation)438 ENDIF ! of if (icelocation) 408 439 409 440 410 441 ! print caps locations - useful for plots too 411 print*,' latitude | longitude | ig'412 do ig=1, ngrid413 dryness 414 415 if (watercaptag (ig)) then416 print*,' ice water cap', lati(ig)*180./pi,417 . long(ig)*180./pi, ig442 print*,'surfini: latitude | longitude | ig' 443 do ig=1,klon_glo 444 dryness_glo(ig) = icedryness 445 446 if (watercaptag_glo(ig)) then 447 print*,'surfini: ice water cap', lati_glo(ig)*180./pi, 448 & long_glo(ig)*180./pi, ig 418 449 endif 419 450 enddo 420 451 452 endif !of if (is_master) 453 454 ! Now scatter fields watercaptag and dryness from master to all 455 ! (is just a plain copy in serial mode) 456 call scatter(dryness_glo,dryness) 457 call scatter(watercaptag_glo,watercaptag) 458 421 459 #endif 422 460 ! end of #else of #ifdef MESOSCALE 423 461 ENDIF ! (caps & water) 424 462 … … 439 477 psolaralb(ig,2)=albedodat(ig) 440 478 END DO 441 PRINT*,' minimum albedo sanswater caps',442 s albedodat(ISMIN(ngrid,albedodat,1))443 PRINT*,' maximum albedo sanswater caps',444 s albedodat(ISMAX(ngrid,albedodat,1))479 PRINT*,'surfini: minimum albedo without water caps', 480 & minval(albedodat) 481 PRINT*,'surfini: maximum albedo without water caps', 482 & maxval(albedodat) 445 483 446 484 c initial albedo if permanent H2O ice is present … … 453 491 ENDIF 454 492 END DO 455 PRINT*,' minimum albedo avecwater caps',456 s psolaralb(ISMIN(ngrid,psolaralb,1),1)457 PRINT*,' maximum albedo avecwater caps',458 s psolaralb(ISMAX(ngrid,psolaralb,1),1)493 PRINT*,'surfini: minimum albedo with water caps', 494 & minval(albedodat) 495 PRINT*,'surfini: maximum albedo with water caps', 496 & maxval(albedodat) 459 497 460 498 ENDIF … … 465 503 DO ig=1,ngrid 466 504 IF (piceco2(ig) .GT. 0.) THEN 467 IF( ig.GT.ngrid/2+1) THEN468 icap=2 505 IF(lati(ig).LT. 0.) THEN 506 icap=2 ! Southern hemisphere 469 507 ELSE 470 icap=1 508 icap=1 ! Northern hemisphere 471 509 ENDIF 472 510 psolaralb(ig,1) = albedice(icap) … … 514 552 endif 515 553 end do 516 PRINT*,' minimum albedo avec givre etco2',517 s psolaralb(ISMIN(ngrid,psolaralb,1),1)518 PRINT*,' maximum albedo avec givre etco2',519 s psolaralb(ISMAX(ngrid,psolaralb,1),1)554 PRINT*,'surfini: minimum albedo with frost and co2', 555 & minval(albedodat) 556 PRINT*,'surfini: maximum albedo with frost and co2', 557 & maxval(albedodat) 520 558 ELSE 521 559 watercaptag(:) = .false. 522 END IF 560 END IF ! OF IF(water) 523 561 524 562 RETURN -
trunk/LMDZ.MARS/libf/phymars/tabfi.F
r1112 r1130 48 48 & iceradius, dtemisice, iceradius 49 49 use yomaer_h, only: tauvis 50 use iostart, only: get_var 51 use mod_phys_lmdz_para, only: is_parallel 50 52 implicit none 51 53 … … 67 69 c Arguments 68 70 c --------- 69 INTEGER nid,nvarid,tab070 INTEGER*4 day_ini71 INTEGER Lmodif72 INTEGER lmax73 REAL p_rad,p_omeg,p_g,p_mugaz,p_daysec,time,peri_ls71 INTEGER,INTENT(IN) :: nid,tab0 72 INTEGER*4,INTENT(OUT) :: day_ini 73 INTEGER,INTENT(IN) :: Lmodif 74 INTEGER,INTENT(OUT) :: lmax 75 REAL,INTENT(OUT) :: p_rad,p_omeg,p_g,p_mugaz,p_daysec,time 74 76 75 77 c Variables 76 78 c --------- 79 INTEGER :: nvarid 80 REAL :: peri_ls 77 81 INTEGER length 78 82 parameter (length = 100) … … 81 85 INTEGER size 82 86 CHARACTER modif*20 83 84 c Fonctions DRS et autres 85 c ----------------------- 86 INTEGER setname, cluvdb, getdat 87 87 LOGICAL :: found 88 89 write(*,*)"tabfi: nid=",nid," tab0=",tab0," Lmodif=",Lmodif 90 88 91 c----------------------------------------------------------------------- 89 92 c Initialization of various physical constants to defaut values (nid = 0 case) … … 150 153 c Read 'controle' array 151 154 c 152 ierr = NF_INQ_VARID (nid, "controle", nvarid) 153 IF (ierr .NE. NF_NOERR) THEN 154 PRINT*, "Tabfi: Could not find <controle> data" 155 CALL abort 156 ENDIF 157 #ifdef NC_DOUBLE 158 ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tab_cntrl) 159 #else 160 ierr = NF_GET_VAR_REAL(nid, nvarid, tab_cntrl) 161 #endif 162 IF (ierr .NE. NF_NOERR) THEN 163 PRINT*, "Tabfi: Failed reading <controle> array" 164 CALL abort 165 ENDIF 166 167 print*,'tabfi: tab_cntrl',tab_cntrl 155 ! ierr = NF_INQ_VARID (nid, "controle", nvarid) 156 ! IF (ierr .NE. NF_NOERR) THEN 157 ! PRINT*, "Tabfi: Could not find <controle> data" 158 ! CALL abort 159 ! ENDIF 160 !#ifdef NC_DOUBLE 161 ! ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tab_cntrl) 162 !#else 163 ! ierr = NF_GET_VAR_REAL(nid, nvarid, tab_cntrl) 164 !#endif 165 ! IF (ierr .NE. NF_NOERR) THEN 166 ! PRINT*, "Tabfi: Failed reading <controle> array" 167 ! CALL abort 168 ! ENDIF 169 170 call get_var("controle",tab_cntrl,found) 171 if (.not.found) then 172 write(*,*)"tabfi: Failed reading <controle> array" 173 call abort 174 else 175 write(*,*)'tabfi: tab_cntrl',tab_cntrl 176 endif 168 177 c 169 178 c Initialization of some physical constants … … 269 278 c----------------------------------------------------------------------- 270 279 c Modifications... 280 ! NB: Modifying controls should only be done by newstart, and in seq mode 281 if ((Lmodif.eq.1).and.is_parallel) then 282 write(*,*) "tabfi: Error modifying tab_control should", 283 & " only happen in serial mode (eg: by newstart)" 284 stop 285 endif 271 286 c----------------------------------------------------------------------- 272 287 -
trunk/LMDZ.MARS/libf/phymars/testphys1d.F
r1112 r1130 3 3 ! to use 'getin' 4 4 USE ioipsl_getincom, only: getin 5 use infotrac, only: nqtot, tn om6 use comsoil_h, only: volcapa, layer, mlayer, inertiedat 5 use infotrac, only: nqtot, tname 6 use comsoil_h, only: volcapa, layer, mlayer, inertiedat, nsoilmx 7 7 use comgeomfi_h, only: lati, long, area 8 8 use comdiurn_h, only: sinlat … … 13 13 use slope_mod, only: theta_sl, psi_sl 14 14 use yomaer_h, only: tauvis 15 use control_mod, only: day_step 16 use phyredem, only: physdem0,physdem1 17 use comgeomphy, only: initcomgeomphy 15 18 IMPLICIT NONE 16 19 … … 36 39 #include "dimensions.h" 37 40 #include "dimphys.h" 41 integer, parameter :: ngrid = 1 !(2+(jjm-1)*iim - 1/jjm) 38 42 !#include "dimradmars.h" 39 43 !#include "comgeomfi.h" … … 47 51 !#include "comsaison.h" 48 52 !#include "yomaer.h" 49 #include "control.h"53 !#include "control.h" 50 54 #include "comvert.h" 51 55 #include "netcdf.inc" … … 70 74 REAL play(nlayermx) ! Pressure at the middle of the layers (Pa) 71 75 REAL plev(nlayermx+1) ! intermediate pressure levels (pa) 72 REAL psurf,tsurf 76 REAL psurf,tsurf(1) 73 77 REAL u(nlayermx),v(nlayermx) ! zonal, meridional wind 74 78 REAL gru,grv ! prescribed "geostrophic" background wind … … 77 81 REAL,ALLOCATABLE :: qsurf(:) ! tracer surface budget (e.g. kg.m-2) 78 82 REAL tsoil(nsoilmx) ! subsurface soik temperature (K) 79 REAL co2ice 80 REAL emis 83 REAL co2ice(1) ! co2ice layer (kg.m-2) 84 REAL emis(1) ! surface layer 81 85 REAL q2(nlayermx+1) ! Turbulent Kinetic Energy 82 86 REAL zlay(nlayermx) ! altitude estimee dans les couches (km) … … 111 115 c INITIALISATION 112 116 c======================================================================= 117 ! initialize "serial/parallel" related stuff 118 ! CALL init_phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/)) 119 CALL init_phys_lmdz(iim,jjm+1,llm,1,(/(jjm-1)*iim+2/)) 120 call initcomgeomphy 113 121 114 122 c ------------------------------------------------------ … … 203 211 endif 204 212 ! allocate arrays: 205 allocate(tn om(nq))213 allocate(tname(nq)) 206 214 allocate(q(nlayermx,nq)) 207 215 allocate(qsurf(nq)) … … 212 220 ! read tracer names from file traceur.def 213 221 do iq=1,nq 214 read(90,*,iostat=ierr) tn om(iq)222 read(90,*,iostat=ierr) tname(iq) 215 223 if (ierr.ne.0) then 216 224 write(*,*) 'testphys1d: error reading tracer names...' … … 228 236 do iq=1,nq 229 237 txt="" 230 write(txt,"(a)") tn om(iq)238 write(txt,"(a)") tname(iq) 231 239 write(*,*)" tracer:",trim(txt) 232 240 ! CO2 … … 366 374 nq=1 367 375 ! allocate arrays: 368 allocate(tn om(nq))376 allocate(tname(nq)) 369 377 allocate(q(nlayermx,nq)) 370 378 allocate(qsurf(nq)) … … 374 382 do iq=1,nq 375 383 write(str7,'(a1,i2.2)')'q',iq 376 tn om(iq)=str7384 tname(iq)=str7 377 385 enddo 378 386 ! and just to be clean, also initialize tracers to zero for physdem1 … … 549 557 c CO2 ice on the surface 550 558 c ------------------- 551 co2ice =0.E+0 ! default value for co2ice559 co2ice(1)=0.E+0 ! default value for co2ice 552 560 PRINT *,'Initial CO2 ice on the surface (kg.m-2)' 553 561 call getin("co2ice",co2ice) … … 558 566 c ---------- 559 567 emis=emissiv 560 IF (co2ice .eq.1.E+0) THEN568 IF (co2ice(1).eq.1.E+0) THEN 561 569 emis=emisice(1) ! northern hemisphere 562 570 IF(lati(1).LT.0) emis=emisice(2) ! southern hemisphere … … 615 623 DO isoil=1,nsoil 616 624 inertiedat(1,isoil)=inertiedat(1,1) ! soil thermal inertia 617 tsoil(isoil)=tsurf ! soil temperature625 tsoil(isoil)=tsurf(1) ! soil temperature 618 626 ENDDO 619 627 … … 817 825 818 826 #include "../dyn3d/disvert.F" 827 #include "../dyn3d/abort_gcm.F" -
trunk/LMDZ.MARS/libf/phymars/thermcell_main_mars.F90
r1127 r1130 43 43 44 44 USE comtherm_h 45 use planetwide_mod, only: planetwide_maxval 45 46 46 47 IMPLICIT NONE … … 764 765 ! =========================================================================== 765 766 766 zlmax=MAXVAL(lmax(:))+2 767 !zlmax=MAXVAL(lmax(:))+2 ! OK, but in serial mode only; use planet 768 call planetwide_maxval(lmax,zlmax) 769 zlmax=zlmax+2 770 767 771 if (zlmax .ge. nlayer) then 768 772 print*,'thermals have reached last layer of the model' … … 790 794 791 795 ! llmax is the index of the heighest thermal in the simulation domain 792 llmax=1 793 do ig=1,ngrid 794 if (lalim(ig)>llmax) llmax=lalim(ig) 795 enddo 796 !llmax=1 797 !do ig=1,ngrid 798 ! if (lalim(ig)>llmax) llmax=lalim(ig) 799 !enddo 800 call planetwide_maxval(lalim,llmax) 796 801 797 802 ! Integral of a**2/(rho* Delta z), see equation 13 of appendix 4.2 in paper -
trunk/LMDZ.MARS/libf/phymars/vdif_kc.F
r1047 r1130 32 32 c 33 33 c....................................................................... 34 REAL dt,g35 REAL zlev(ngrid,nlay+1)36 REAL zlay(ngrid,nlay)37 REAL u(ngrid,nlay)38 REAL v(ngrid,nlay)39 REAL teta(ngrid,nlay)40 REAL cd(ngrid)41 REAL q2(ngrid,nlay+1)42 REAL km(ngrid,nlay+1)43 REAL kn(ngrid,nlay+1)44 REAL zq(ngrid,nlay,nq)34 REAL,INTENT(IN) :: dt,g 35 REAL,INTENT(IN) :: zlev(ngrid,nlay+1) 36 REAL,INTENT(IN) :: zlay(ngrid,nlay) 37 REAL,INTENT(IN) :: u(ngrid,nlay) 38 REAL,INTENT(IN) :: v(ngrid,nlay) 39 REAL,INTENT(IN) :: teta(ngrid,nlay) 40 REAL,INTENT(IN) :: cd(ngrid) 41 REAL,INTENT(INOUT) :: q2(ngrid,nlay+1) 42 REAL,INTENT(OUT) :: km(ngrid,nlay+1) 43 REAL,INTENT(OUT) :: kn(ngrid,nlay+1) 44 REAL,INTENT(IN) :: zq(ngrid,nlay,nq) 45 45 c....................................................................... 46 46 c … … 247 247 nlev=nlay+1 248 248 249 ! Other initializations of local variables (to be clean) 250 long(:,:)=0. 251 n2(:,:)=0. 252 sn(:,:)=0. 253 snq2(:,:)=0. 254 sm(:,:)=0. 255 smq2(:,:)=0. 249 256 c....................................................................... 250 257 c Special treatment for co2 … … 381 388 gninf=.false. 382 389 gnsup=.false. 383 long(igrid,ilev)=long(igrid,ilev) 384 long(igrid,ilev)=long(igrid,ilev) 390 long(igrid,ilev)=long(igrid,ilev) ! not very useful... 391 long(igrid,ilev)=long(igrid,ilev) ! not very useful... 385 392 c 386 393 IF (gn.lt.gnmin) THEN … … 609 616 c....................................................................... 610 617 c 618 619 ! call writediagfi(ngrid,'vdif_kc_q2','','',3,q2(:,1:nlay)) 620 ! call writediagfi(ngrid,'vdif_kc_km','','',3,km(:,1:nlay)) 621 ! call writediagfi(ngrid,'vdif_kc_kn','','',3,kn(:,1:nlay)) 622 ! call writediagfi(ngrid,'vdif_kc_unsdz','','',3,unsdz(:,1:nlay)) 623 ! call writediagfi(ngrid,'vdif_kc_unsddecz','','',3, 624 ! & unsdzdec(:,1:nlay)) 625 ! call writediagfi(ngrid,'vdif_kc_q','','',3,q(:,1:nlay)) 626 ! call writediagfi(ngrid,'vdif_kc_kmpre','','',3, 627 ! & kmpre(:,1:nlay)) 628 ! call writediagfi(ngrid,'vdif_kc_long','','',3,long(:,1:nlay)) 629 ! call writediagfi(ngrid,'vdif_kc_sn','','',3,sn(:,1:nlay)) 630 ! call writediagfi(ngrid,'vdif_kc_sm','','',3,sm(:,1:nlay)) 631 611 632 RETURN 612 633 END -
trunk/LMDZ.MARS/libf/phymars/vdifc.F
r1047 r1130 56 56 REAL,INTENT(IN) :: pu(ngrid,nlay),pv(ngrid,nlay) 57 57 REAL,INTENT(IN) :: ph(ngrid,nlay) 58 REAL :: pt(ngrid,nlay)59 58 REAL,INTENT(IN) :: ptsrf(ngrid),pemis(ngrid) 60 59 REAL,INTENT(IN) :: pdufi(ngrid,nlay),pdvfi(ngrid,nlay) … … 63 62 REAL,INTENT(OUT) :: pdudif(ngrid,nlay),pdvdif(ngrid,nlay) 64 63 REAL,INTENT(OUT) :: pdtsrf(ngrid),pdhdif(ngrid,nlay) 65 REAL,INTENT(IN) :: pcapcal(ngrid)66 REAL pq2(ngrid,nlay+1)64 REAL,INTENT(IN) :: pcapcal(ngrid) 65 REAL,INTENT(INOUT) :: pq2(ngrid,nlay+1) 67 66 68 67 c Argument added for condensation: … … 86 85 c ------ 87 86 87 REAL :: pt(ngrid,nlay) 88 88 REAL ust(ngrid),tst(ngrid) 89 89 … … 363 363 ! Some usefull diagnostics for the new surface layer parametrization : 364 364 365 ! call WRITEDIAGFI(ngrid,' pcdv',365 ! call WRITEDIAGFI(ngrid,'vdifc_zcdv_true', 366 366 ! & 'momentum drag','no units', 367 367 ! & 2,zcdv_true) 368 ! call WRITEDIAGFI(ngrid,' pcdh',368 ! call WRITEDIAGFI(ngrid,'vdifc_zcdh_true', 369 369 ! & 'heat drag','no units', 370 370 ! & 2,zcdh_true) 371 ! call WRITEDIAGFI(ngrid,' ust',371 ! call WRITEDIAGFI(ngrid,'vdifc_ust', 372 372 ! & 'friction velocity','m/s',2,ust) 373 ! call WRITEDIAGFI(ngrid,' tst',373 ! call WRITEDIAGFI(ngrid,'vdifc_tst', 374 374 ! & 'friction temperature','K',2,tst) 375 ! call WRITEDIAGFI(ngrid,' rm-1',375 ! call WRITEDIAGFI(ngrid,'vdifc_zcdv', 376 376 ! & 'aerodyn momentum conductance','m/s', 377 377 ! & 2,zcdv) 378 ! call WRITEDIAGFI(ngrid,' rh-1',378 ! call WRITEDIAGFI(ngrid,'vdifc_zcdh', 379 379 ! & 'aerodyn heat conductance','m/s', 380 380 ! & 2,zcdh) … … 384 384 IF (.not. calltherm) THEN 385 385 386 CALL vdif_kc( ptimestep,g,pzlev,pzlay386 CALL vdif_kc(ngrid,nlay,nq,ptimestep,g,pzlev,pzlay 387 387 & ,pu,pv,ph,zcdv_true 388 388 & ,pq2,zkv,zkh,zq) -
trunk/LMDZ.MARS/libf/phymars/writediagfi.F
r1047 r1130 40 40 !================================================================= 41 41 use surfdat_h, only: phisfi 42 use control_mod, only: ecritphy, day_step, iphysiq 43 USE mod_phys_lmdz_para, only : is_parallel, is_mpi_root, 44 & is_master, gather 45 USE mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo 42 46 implicit none 43 47 … … 46 50 !#include "dimphys.h" 47 51 #include "paramet.h" 48 #include "control.h"52 !#include "control.h" 49 53 #include "comvert.h" 50 54 #include "comgeom.h" … … 97 101 98 102 #ifndef MESOSCALE 103 104 #ifdef CPP_PARA 105 ! Added to work in parallel mode 106 real dx3_glop(klon_glo,llm) 107 real dx3_glo(iim,jjp1,llm) ! to store a global 3D data set 108 real dx2_glop(klon_glo) 109 real dx2_glo(iim,jjp1) ! to store a global 2D (surface) data set 110 real px2(ngrid) 111 ! real dx1_glo(llm) ! to store a 1D (column) data set 112 ! real dx0_glo 113 real phisfi_glo(klon_glo) ! surface geopotential on global physics grid 114 #else 115 real phisfi_glo(ngrid) ! surface geopotential on global physics grid 116 #endif 117 99 118 !*************************************************************** 100 119 !Sortie des variables au rythme voulu … … 162 181 stop 163 182 endif 183 184 zitau = -1 ! initialize zitau 185 186 #ifdef CPP_PARA 187 ! Gather phisfi() geopotential on physics grid 188 call Gather(phisfi,phisfi_glo) 189 #else 190 phisfi_glo(:)=phisfi(:) 191 #endif 192 193 !! parallel: we cannot use the usual writediagfi method 194 !! call iophys_ini 195 if (is_master) then 196 ! only the master is required to do this 164 197 165 198 ! Create the NetCDF file 166 ierr = NF_CREATE(fichnom, IOR(NF_CLOBBER,NF_64BIT_OFFSET), nid)199 ierr = NF_CREATE(fichnom, NF_CLOBBER, nid) 167 200 ! Define the 'Time' dimension 168 201 ierr = nf_def_dim(nid,"Time",NF_UNLIMITED,idim) … … 183 216 184 217 ! write "header" of file (longitudes, latitudes, geopotential, ...) 185 call gr_fi_dyn(1, ngrid,iip1,jjp1,phisfi,phis)218 call gr_fi_dyn(1,size(phisfi_glo),iip1,jjp1,phisfi_glo,phis) 186 219 call iniwrite(nid,day_ini,phis) 187 188 zitau = -1 ! initialize zitau 220 221 endif ! of if (is_master) 222 189 223 else 190 ! Open the NetCDF file 191 ierr = NF_OPEN(fichnom,NF_WRITE,nid) 224 225 if (is_master) then 226 ! only the master is required to do this 227 228 ! Open the NetCDF file 229 ierr = NF_OPEN(fichnom,NF_WRITE,nid) 230 endif ! of if (is_master) 231 192 232 endif ! if (firstnom.eq.'1234567890') 193 233 … … 218 258 !-------------------------------------------------------- 219 259 260 if (is_master) then 261 ! only the master is required to do this 220 262 if (nom.eq.firstnom) then 221 263 ! We have identified a "first call" (at given date) … … 241 283 end if ! of if (nom.eq.firstnom) 242 284 285 endif ! of if (is_master) 286 243 287 !Case of a 3D variable 244 288 !--------------------- 245 289 if (dim.eq.3) then 246 290 291 #ifdef CPP_PARA 292 ! Gather field on a "global" (without redundant longitude) array 293 call Gather(px,dx3_glop) 294 !$OMP MASTER 295 if (is_mpi_root) then 296 call Grid1Dto2D_glo(dx3_glop,dx3_glo) 297 ! copy dx3_glo() to dx3(:) and add redundant longitude 298 dx3(1:iim,:,:)=dx3_glo(1:iim,:,:) 299 dx3(iip1,:,:)=dx3(1,:,:) 300 endif 301 !$OMP END MASTER 302 !$OMP BARRIER 303 #else 247 304 ! Passage variable physique --> variable dynamique 248 305 ! recast (copy) variable from physics grid to dynamics grid … … 260 317 ENDDO 261 318 ENDDO 262 319 #endif 263 320 ! Ecriture du champs 264 321 265 ! write (*,*) 'In writediagfi, on sauve: ' , nom 266 ! write (*,*) 'In writediagfi. Estimated date = ' ,date 322 if (is_master) then 323 ! only the master writes to output 267 324 ! name of the variable 268 325 ierr= NF_INQ_VARID(nid,nom,varid) … … 294 351 ! ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx3) 295 352 !#else 353 ! write(*,*)"test: nid=",nid," varid=",varid 354 ! write(*,*)" corner()=",corner 355 ! write(*,*)" edges()=",edges 356 ! write(*,*)" dx3()=",dx3 296 357 ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx3) 297 358 !#endif … … 300 361 write(*,*) "***** PUT_VAR problem in writediagfi" 301 362 write(*,*) "***** with ",nom 302 write(*,*) 'ierr=', ierr 363 write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr) 303 364 c call abort 304 365 endif 305 366 367 endif !of if (is_master) 368 306 369 !Case of a 2D variable 307 370 !--------------------- 308 371 309 372 else if (dim.eq.2) then 373 374 #ifdef CPP_PARA 375 ! Gather field on a "global" (without redundant longitude) array 376 px2(:)=px(:,1) 377 call Gather(px2,dx2_glop) 378 !$OMP MASTER 379 if (is_mpi_root) then 380 call Grid1Dto2D_glo(dx2_glop,dx2_glo) 381 ! copy dx2_glo() to dx2(:) and add redundant longitude 382 dx2(1:iim,:)=dx2_glo(1:iim,:) 383 dx2(iip1,:)=dx2(1,:) 384 endif 385 !$OMP END MASTER 386 !$OMP BARRIER 387 #else 310 388 311 389 ! Passage variable physique --> physique dynamique … … 323 401 dx2(iip1,j)=dx2(1,j) 324 402 ENDDO 325 403 #endif 404 405 if (is_master) then 406 ! only the master writes to output 326 407 ! write (*,*) 'In writediagfi, on sauve: ' , nom 327 408 ! write (*,*) 'In writediagfi. Estimated date = ' ,date … … 359 440 write(*,*) "***** PUT_VAR matter in writediagfi" 360 441 write(*,*) "***** with ",nom 361 write(*,*) 'ierr=', ierr 442 write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr) 362 443 c call abort 363 444 endif 364 445 446 endif !of if (is_master) 447 365 448 !Case of a 1D variable (ie: a column) 366 449 !--------------------------------------------------- 367 450 368 451 else if (dim.eq.1) then 452 if (is_parallel) then 453 write(*,*) "writediagfi error: dim=1 not implemented ", 454 & "in parallel mode" 455 stop 456 endif 369 457 ! Passage variable physique --> physique dynamique 370 458 ! recast (copy) variable from physics grid to dynamics grid … … 402 490 write(*,*) "***** PUT_VAR problem in writediagfi" 403 491 write(*,*) "***** with ",nom 404 write(*,*) 'ierr=', ierr 492 write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr) 405 493 c call abort 406 494 endif … … 410 498 411 499 else if (dim.eq.0) then 500 412 501 dx0 = px (1,1) 413 502 503 if (is_master) then 504 ! only the master writes to output 414 505 ierr= NF_INQ_VARID(nid,nom,varid) 415 506 if (ierr /= NF_NOERR) then … … 437 528 write(*,*) "***** PUT_VAR matter in writediagfi" 438 529 write(*,*) "***** with ",nom 439 write(*,*) 'ierr=', ierr 530 write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr) 440 531 c call abort 441 532 endif 442 533 534 endif !of if (is_master) 535 443 536 endif ! of if (dim.eq.3) elseif(dim.eq.2)... 444 537 445 538 endif ! of if ( MOD(zitau+1,irythme) .eq.0.) 446 539 447 ierr= NF_CLOSE(nid) 540 if (is_master) then 541 ierr= NF_CLOSE(nid) 542 endif 448 543 449 544 #endif -
trunk/LMDZ.MARS/libf/phymars/writediagsoil.F90
r1047 r1130 13 13 14 14 use comsoil_h, only: nsoilmx 15 use control_mod, only: ecritphy, day_step, iphysiq 16 use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather 17 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo 15 18 16 19 implicit none … … 19 22 !#include"dimphys.h" 20 23 #include"paramet.h" 21 #include"control.h"24 !#include"control.h" 22 25 !#include"comsoil.h" 23 26 #include"netcdf.inc" … … 56 59 integer,dimension(4) :: edges,corners 57 60 61 #ifdef CPP_PARA 62 ! Added to work in parallel mode 63 real dx3_glop(klon_glo,nsoilmx) 64 real dx3_glo(iim,jjp1,nsoilmx) ! to store a global 3D data set 65 real dx2_glop(klon_glo) 66 real dx2_glo(iim,jjp1) ! to store a global 2D (surface) data set 67 real px2(ngrid) 68 #endif 69 58 70 ! 1. Initialization step 59 71 if (firstname.eq."1234567890") then … … 75 87 76 88 ! Create output NetCDF file 77 ierr=NF_CREATE(filename,IOR(NF_CLOBBER,NF_64BIT_OFFSET),nid) 78 if (ierr.ne.NF_NOERR) then 89 if (is_master) then 90 ierr=NF_CREATE(filename,NF_CLOBBER,nid) 91 if (ierr.ne.NF_NOERR) then 79 92 write(*,*)'writediagsoil: Error, failed creating file '//trim(filename) 80 93 stop 81 endif 82 94 endif 95 endif ! of if (is_master) 96 83 97 ! Define dimensions and axis attributes 84 98 call iniwritesoil(nid,ngrid) … … 89 103 else 90 104 ! If not an initialization call, simply open the NetCDF file 91 ierr=NF_OPEN(filename,NF_WRITE,nid) 105 if (is_master) then 106 ierr=NF_OPEN(filename,NF_WRITE,nid) 107 endif 92 108 endif ! of if (firstname.eq."1234567890") 93 109 … … 105 121 if (name.eq.firstname) then 106 122 ntime=ntime+1 107 date= real(zitau+1)/real(day_step)123 date=float(zitau+1)/float(day_step) 108 124 ! Note: day_step is known from control.h 109 125 110 ! Get NetCDF ID for "time" 111 ierr=NF_INQ_VARID(nid,"time",varid) 112 ! Add the current value of date to the "time" array 126 if (is_master) then 127 ! Get NetCDF ID for "time" 128 ierr=NF_INQ_VARID(nid,"time",varid) 129 ! Add the current value of date to the "time" array 113 130 !#ifdef NC_DOUBLE 114 ! ierr=NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)131 ! ierr=NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date) 115 132 !#else 116 ierr=NF_PUT_VARA_REAL(nid,varid,ntime,1,date)133 ierr=NF_PUT_VARA_REAL(nid,varid,ntime,1,date) 117 134 !#endif 118 if (ierr.ne.NF_NOERR) then135 if (ierr.ne.NF_NOERR) then 119 136 write(*,*)"writediagsoil: Failed writing date to time variable" 120 137 stop 121 endif 138 endif 139 endif ! of if (is_master) 122 140 endif ! of if (name.eq.firstname) 123 141 … … 125 143 if (dimpx.eq.3) then ! Case of a 3D variable 126 144 ! A. Recast data along 'dynamics' grid 145 #ifdef CPP_PARA 146 ! gather field on a "global" (without redundant longitude) array 147 call Gather(px,dx3_glop) 148 !$OMP MASTER 149 if (is_mpi_root) then 150 call Grid1Dto2D_glo(dx3_glop,dx3_glo) 151 ! copy dx3_glo() to dx3(:) and add redundant longitude 152 data3(1:iim,:,:)=dx3_glo(1:iim,:,:) 153 data3(iip1,:,:)=data3(1,:,:) 154 endif 155 !$OMP END MASTER 156 !$OMP BARRIER 157 #else 127 158 do l=1,nsoilmx 128 159 ! handle the poles … … 140 171 enddo 141 172 enddo 173 #endif 142 174 143 175 ! B. Write (append) the variable to the NetCDF file 176 if (is_master) then 144 177 ! B.1. Get the ID of the variable 145 178 ierr=NF_INQ_VARID(nid,name,varid) … … 179 212 " to file "//trim(filename)//" at time",date 180 213 endif 214 endif ! of if (is_master) 181 215 182 216 elseif (dimpx.eq.2) then ! Case of a 2D variable 217 183 218 ! A. Recast data along 'dynamics' grid 219 #ifdef CPP_PARA 220 ! gather field on a "global" (without redundant longitude) array 221 px2(:)=px(:,1) 222 call Gather(px2,dx2_glop) 223 !$OMP MASTER 224 if (is_mpi_root) then 225 call Grid1Dto2D_glo(dx2_glop,dx2_glo) 226 ! copy dx3_glo() to dx3(:) and add redundant longitude 227 data2(1:iim,:)=dx2_glo(1:iim,:) 228 data2(iip1,:)=data2(1,:) 229 endif 230 !$OMP END MASTER 231 !$OMP BARRIER 232 #else 184 233 ! handle the poles 185 234 do i=1,iip1 … … 195 244 data2(iip1,j)=data2(1,j) ! extra (modulo) longitude 196 245 enddo 246 #endif 197 247 198 248 ! B. Write (append) the variable to the NetCDF file 249 if (is_master) then 199 250 ! B.1. Get the ID of the variable 200 251 ierr=NF_INQ_VARID(nid,name,varid) … … 231 282 " to file "//trim(filename)//" at time",date 232 283 endif 284 endif ! of if (is_master) 233 285 234 286 elseif (dimpx.eq.0) then ! Case of a 0D variable 287 #ifdef CPP_PARA 288 write(*,*) "writediagsoil: dimps==0 case not implemented in // mode!!" 289 stop 290 #endif 235 291 ! A. Copy data value 236 292 data0=px(1,1) … … 270 326 271 327 ! 4. Close the NetCDF file 272 ierr=NF_CLOSE(nid) 328 if (is_master) then 329 ierr=NF_CLOSE(nid) 330 endif 273 331 274 332 end subroutine writediagsoil -
trunk/LMDZ.MARS/libf/phymars/wstats.F90
r719 r1130 1 1 subroutine wstats(ngrid,nom,titre,unite,dim,px) 2 3 use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather, klon_mpi_begin 4 use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo 2 5 3 6 implicit none … … 5 8 #include "dimensions.h" 6 9 #include "dimphys.h" 10 #include "comconst.h" 7 11 #include "statto.h" 8 12 #include "netcdf.inc" … … 11 15 character (len=*),intent(in) :: nom,titre,unite 12 16 integer,intent(in) :: dim 13 real, dimension(ngrid,llm),intent(in) :: px14 17 integer,parameter :: iip1=iim+1 15 18 integer,parameter :: jjp1=jjm+1 19 real,intent(in) :: px(ngrid,llm) 16 20 real, dimension(iip1,jjp1,llm) :: mean3d,sd3d,dx3 17 21 real, dimension(iip1,jjp1) :: mean2d,sd2d,dx2 18 22 character (len=50) :: namebis 19 23 character (len=50), save :: firstvar 20 integer :: ierr, ierr2,varid,nbdim,nid24 integer :: ierr,varid,nbdim,nid 21 25 integer :: meanid,sdid 22 integer, dimension(4) :: id,start,size 26 integer, dimension(4) :: id,start,sizes 23 27 logical, save :: firstcall=.TRUE. 24 28 integer :: l,i,j,ig0 25 integer,save :: index 26 ! Added to use stats.def to select output variable 27 logical,save :: stats_def 28 logical :: getout 29 integer,save :: n_nom_def 30 integer :: n 31 integer,parameter :: n_nom_def_max=99 32 character(len=20),save :: nom_def(n_nom_def_max) 33 logical, save :: notfoundfirst=.TRUE. 29 integer,save :: indx 34 30 35 31 integer, save :: step=0 36 37 38 32 33 ! Added to work in parallel mode 34 #ifdef CPP_PARA 35 real px3_glop(klon_glo,llm) ! to store a 3D data set on global physics grid 36 real px3_glo(iim,jjp1,llm) ! to store a global 3D data set on global lonxlat grid 37 real px2_glop(klon_glo) ! to store a 2D data set on global physics grid 38 real px2_glo(iim,jjp1) ! to store a 2D data set on global lonxlat grid 39 real px2(ngrid) 40 real px3(ngrid,llm) 41 #else 42 ! When not running in parallel mode: 43 real px3_glop(ngrid,llm) ! to store a 3D data set on global physics grid 44 real px3_glo(iim,jjp1,llm) ! to store a global 3D data set on global lonxlat grid 45 real px2_glop(ngrid) ! to store a 2D data set on global physics grid 46 real px2_glo(iim,jjp1) ! to store a 2D data set on global lonxlat grid 47 #endif 48 49 ! 1. Initialization (creation of stats.nc file) 39 50 if (firstcall) then 40 51 firstcall=.false. 52 firstvar=trim((nom)) 41 53 call inistats(ierr) 42 ! at very first call, check if there is a "stats.def" to use and read it 43 open(99,file="stats.def",status='old',form='formatted',iostat=ierr2) 44 if(ierr2.eq.0) then 45 stats_def=.true. 46 write(*,*) "******************" 47 write(*,*) "Reading stats.def" 48 write(*,*) "******************" 49 do n=1,n_nom_def_max 50 read(99,fmt='(a)',end=88) nom_def(n) 51 write(*,*) 'Output in stats: ', trim(nom_def(n)) 52 end do 53 88 continue 54 if (n.ge.n_nom_def_max) then 55 write(*,*)"n_nom_def_max too small in wstats.F90:",n 56 stop 57 end if 58 n_nom_def=n-1 59 close(99) 60 else 61 firstvar=trim((nom)) 62 stats_def=.false. 63 notfoundfirst=.false. 64 endif 65 endif 66 67 ! find firstvar that is in stats.def 68 if (notfoundfirst) then 69 do n=1,n_nom_def_max 70 if(trim((nom_def(n))).eq.trim((nom))) then 71 firstvar=trim((nom)) 72 notfoundfirst=.false. 73 endif 74 end do 75 endif 76 77 ! get out of wstats if there is stats.def AND variable not listed 78 if (stats_def) then 79 getout=.true. 80 do n=1,n_nom_def 81 if(trim(nom_def(n)).eq.nom) getout=.false. 82 end do 83 if (getout) return 84 end if 85 86 if (firstvar==nom) then ! If we're back to the first variable 54 endif 55 56 if (firstvar==nom) then ! If we're back to the first variable, increment time counter 87 57 step = step + 1 88 58 endif 89 59 90 60 if (mod(step,istats).ne.0) then 61 ! if its not time to write to file, exit 91 62 RETURN 92 63 endif 93 64 65 ! collect fields on a global physics grid 66 #ifdef CPP_PARA 67 if (dim.eq.3) then 68 px3(1:ngrid,1:llm)=px(1:ngrid,1:llm) 69 ! Gather fieds on a "global" (without redundant longitude) array 70 call Gather(px3,px3_glop) 71 !$OMP MASTER 72 if (is_mpi_root) then 73 call Grid1Dto2D_glo(px3_glop,px3_glo) 74 ! copy dx3_glo() to dx3(:) and add redundant longitude 75 dx3(1:iim,:,:)=px3_glo(1:iim,:,:) 76 dx3(iip1,:,:)=dx3(1,:,:) 77 endif 78 !$OMP END MASTER 79 !$OMP BARRIER 80 else ! dim.eq.2 81 ! Gather fieds on a "global" (without redundant longitude) array 82 px2(:)=px(:,1) 83 call Gather(px2,px2_glop) 84 !$OMP MASTER 85 if (is_mpi_root) then 86 call Grid1Dto2D_glo(px2_glop,px2_glo) 87 ! copy px2_glo() to dx2(:) and add redundant longitude 88 dx2(1:iim,:)=px2_glo(1:iim,:) 89 dx2(iip1,:)=dx2(1,:) 90 endif 91 !$OMP END MASTER 92 !$OMP BARRIER 93 endif 94 #else 95 if (dim.eq.3) then 96 px3_glop(:,1:llm)=px(:,1:llm) 97 ! Passage variable physique --> variable dynamique 98 DO l=1,llm 99 DO i=1,iim 100 px3_glo(i,1,l)=px(1,l) 101 px3_glo(i,jjp1,l)=px(ngrid,l) 102 ENDDO 103 DO j=2,jjm 104 ig0= 1+(j-2)*iim 105 DO i=1,iim 106 px3_glo(i,j,l)=px(ig0+i,l) 107 ENDDO 108 ENDDO 109 ENDDO 110 else ! dim.eq.2 111 px2_glop(:)=px(:,1) 112 ! Passage variable physique --> physique dynamique 113 DO i=1,iim 114 px2_glo(i,1)=px(1,1) 115 px2_glo(i,jjp1)=px(ngrid,1) 116 ENDDO 117 DO j=2,jjm 118 ig0= 1+(j-2)*iim 119 DO i=1,iim 120 px2_glo(i,j)=px(ig0+i,1) 121 ENDDO 122 ENDDO 123 endif 124 #endif 125 126 ! 2. Write field to file 127 128 if (is_master) then 129 ! only master needs do this 130 94 131 ierr = NF_OPEN("stats.nc",NF_WRITE,nid) 95 132 96 133 namebis=trim(nom) 134 135 ! test: check if that variable already exists in file 97 136 ierr= NF_INQ_VARID(nid,namebis,meanid) 98 137 99 138 if (ierr.ne.NF_NOERR) then 100 139 ! variable not in file, create/define it 101 140 if (firstvar==nom) then 102 ind ex=1103 count =0141 indx=1 142 count(:)=0 104 143 endif 105 144 … … 122 161 write (*,*) "STATS: creation de ",nom 123 162 namebis=trim(nom) 124 call def_var_stats(nid,namebis,titre,unite,nbdim,id,meanid,ierr) 125 call inivar(nid,meanid,ngrid,dim,index,px,ierr) 163 call def_var(nid,namebis,titre,unite,nbdim,id,meanid,ierr) 164 if (dim.eq.3) then 165 call inivar(nid,meanid,size(px3_glop,1),dim,indx,px3_glop,ierr) 166 else ! dim.eq.2 167 call inivar(nid,meanid,size(px2_glop,1),dim,indx,px2_glop,ierr) 168 endif 126 169 namebis=trim(nom)//"_sd" 127 call def_var_stats(nid,namebis,trim(titre)//" total standard deviation over the season",unite,nbdim,id,sdid,ierr) 128 call inivar(nid,sdid,ngrid,dim,index,px,ierr) 170 call def_var(nid,namebis,trim(titre)//" total standard deviation over the season",unite,nbdim,id,sdid,ierr) 171 if (dim.eq.3) then 172 call inivar(nid,sdid,size(px3_glop,1),dim,indx,px3_glop,ierr) 173 else ! dim.eq.2 174 call inivar(nid,sdid,size(px2_glop,1),dim,indx,px2_glop,ierr) 175 endif 129 176 130 177 ierr= NF_CLOSE(nid) … … 132 179 133 180 else 181 ! variable found in file 134 182 namebis=trim(nom)//"_sd" 135 183 ierr= NF_INQ_VARID(nid,namebis,sdid) … … 138 186 139 187 if (firstvar==nom) then 140 count(index)=count(int(index))+1 141 index=index+1 142 if (index>istime) then 143 index=1 144 endif 145 endif 146 147 if (count(index)==0) then 188 count(indx)=count(int(indx))+1 189 indx=indx+1 190 if (indx>istime) then 191 indx=1 192 endif 193 endif 194 195 if (count(indx)==0) then 196 ! very first time we write the variable to file 148 197 if (dim.eq.3) then 149 start=(/1,1,1,ind ex/)150 size =(/iip1,jjp1,llm,1/)151 mean3d =0152 sd3d =0198 start=(/1,1,1,indx/) 199 sizes=(/iip1,jjp1,llm,1/) 200 mean3d(:,:,:)=0 201 sd3d(:,:,:)=0 153 202 else if (dim.eq.2) then 154 start=(/1,1,ind ex,0/)155 size =(/iip1,jjp1,1,0/)156 mean2d =0157 sd2d =0203 start=(/1,1,indx,0/) 204 sizes=(/iip1,jjp1,1,0/) 205 mean2d(:,:)=0 206 sd2d(:,:)=0 158 207 endif 159 208 else 209 ! load values from file 160 210 if (dim.eq.3) then 161 start=(/1,1,1,ind ex/)162 size =(/iip1,jjp1,llm,1/)163 #ifdef NC_DOUBLE 164 ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,size ,mean3d)165 ierr = NF_GET_VARA_DOUBLE(nid,sdid,start,size ,sd3d)166 #else 167 ierr = NF_GET_VARA_REAL(nid,meanid,start,size ,mean3d)168 ierr = NF_GET_VARA_REAL(nid,sdid,start,size ,sd3d)211 start=(/1,1,1,indx/) 212 sizes=(/iip1,jjp1,llm,1/) 213 #ifdef NC_DOUBLE 214 ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,sizes,mean3d) 215 ierr = NF_GET_VARA_DOUBLE(nid,sdid,start,sizes,sd3d) 216 #else 217 ierr = NF_GET_VARA_REAL(nid,meanid,start,sizes,mean3d) 218 ierr = NF_GET_VARA_REAL(nid,sdid,start,sizes,sd3d) 169 219 #endif 170 220 if (ierr.ne.NF_NOERR) then … … 174 224 175 225 else if (dim.eq.2) then 176 start=(/1,1,ind ex,0/)177 size =(/iip1,jjp1,1,0/)178 #ifdef NC_DOUBLE 179 ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,size ,mean2d)180 ierr = NF_GET_VARA_DOUBLE(nid,sdid,start,size ,sd2d)181 #else 182 ierr = NF_GET_VARA_REAL(nid,meanid,start,size ,mean2d)183 ierr = NF_GET_VARA_REAL(nid,sdid,start,size ,sd2d)226 start=(/1,1,indx,0/) 227 sizes=(/iip1,jjp1,1,0/) 228 #ifdef NC_DOUBLE 229 ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,sizes,mean2d) 230 ierr = NF_GET_VARA_DOUBLE(nid,sdid,start,sizes,sd2d) 231 #else 232 ierr = NF_GET_VARA_REAL(nid,meanid,start,sizes,mean2d) 233 ierr = NF_GET_VARA_REAL(nid,sdid,start,sizes,sd2d) 184 234 #endif 185 235 if (ierr.ne.NF_NOERR) then … … 188 238 endif 189 239 endif 190 endif 240 endif ! of if (count(indx)==0) 241 242 243 ! 2.1. Build dx* (data on lon-lat grid, with redundant longitude) 191 244 192 245 if (dim.eq.3) then 246 dx3(1:iim,:,:)=px3_glo(:,:,:) 247 dx3(iip1,:,:)=dx3(1,:,:) 248 else ! dim.eq.2 249 dx2(1:iim,:)=px2_glo(:,:) 250 dx2(iip1,:)=dx2(1,:) 251 endif 252 253 254 ! 2.2. Add current values to previously stored sums 255 256 if (dim.eq.3) then 257 258 mean3d(:,:,:)=mean3d(:,:,:)+dx3(:,:,:) 259 sd3d(:,:,:)=sd3d(:,:,:)+dx3(:,:,:)**2 260 261 #ifdef NC_DOUBLE 262 ierr = NF_PUT_VARA_DOUBLE(nid,meanid,start,sizes,mean3d) 263 ierr = NF_PUT_VARA_DOUBLE(nid,sdid,start,sizes,sd3d) 264 #else 265 ierr = NF_PUT_VARA_REAL(nid,meanid,start,sizes,mean3d) 266 ierr = NF_PUT_VARA_REAL(nid,sdid,start,sizes,sd3d) 267 #endif 268 269 else if (dim.eq.2) then 270 271 mean2d(:,:)= mean2d(:,:)+dx2(:,:) 272 sd2d(:,:)=sd2d(:,:)+dx2(:,:)**2 273 274 #ifdef NC_DOUBLE 275 ierr = NF_PUT_VARA_DOUBLE(nid,meanid,start,sizes,mean2d) 276 ierr = NF_PUT_VARA_DOUBLE(nid,sdid,start,sizes,sd2d) 277 #else 278 ierr = NF_PUT_VARA_REAL(nid,meanid,start,sizes,mean2d) 279 ierr = NF_PUT_VARA_REAL(nid,sdid,start,sizes,sd2d) 280 #endif 281 282 endif ! of if (dim.eq.3) elseif (dim.eq.2) 283 284 ierr= NF_CLOSE(nid) 285 endif ! of if (is_master) 286 287 end subroutine wstats 288 289 !====================================================== 290 subroutine inivar(nid,varid,ngrid,dim,indx,px,ierr) 291 292 implicit none 293 294 include "dimensions.h" 295 include "dimphys.h" 296 include "netcdf.inc" 297 298 integer, intent(in) :: nid,varid,dim,indx,ngrid 299 real, dimension(ngrid,llm), intent(in) :: px 300 integer, intent(out) :: ierr 301 302 integer,parameter :: iip1=iim+1 303 integer,parameter :: jjp1=jjm+1 304 305 integer :: l,i,j,ig0 306 integer, dimension(4) :: start,sizes 307 real, dimension(iip1,jjp1,llm) :: dx3 308 real, dimension(iip1,jjp1) :: dx2 309 310 if (dim.eq.3) then 311 312 start=(/1,1,1,indx/) 313 sizes=(/iip1,jjp1,llm,1/) 193 314 194 315 ! Passage variable physique --> variable dynamique … … 208 329 ENDDO 209 330 210 mean3d(:,:,:)= mean3d(:,:,:)+dx3(:,:,:) 211 sd3d(:,:,:)= sd3d(:,:,:)+dx3(:,:,:)**2 212 213 #ifdef NC_DOUBLE 214 ierr = NF_PUT_VARA_DOUBLE(nid,meanid,start,size,mean3d) 215 ierr = NF_PUT_VARA_DOUBLE(nid,sdid,start,size,sd3d) 216 #else 217 ierr = NF_PUT_VARA_REAL(nid,meanid,start,size,mean3d) 218 ierr = NF_PUT_VARA_REAL(nid,sdid,start,size,sd3d) 219 #endif 220 if (ierr.ne.NF_NOERR) then 221 write (*,*) NF_STRERROR(ierr) 222 stop "" 223 endif 331 #ifdef NC_DOUBLE 332 ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx3) 333 #else 334 ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx3) 335 #endif 224 336 225 337 else if (dim.eq.2) then 338 339 start=(/1,1,indx,0/) 340 sizes=(/iip1,jjp1,1,0/) 226 341 227 342 ! Passage variable physique --> physique dynamique … … 239 354 ENDDO 240 355 241 mean2d(:,:)= mean2d(:,:)+dx2(:,:) 242 sd2d(:,:)= sd2d(:,:)+dx2(:,:)**2 243 244 #ifdef NC_DOUBLE 245 ierr = NF_PUT_VARA_DOUBLE(nid,meanid,start,size,mean2d) 246 ierr = NF_PUT_VARA_DOUBLE(nid,sdid,start,size,sd2d) 247 #else 248 ierr = NF_PUT_VARA_REAL(nid,meanid,start,size,mean2d) 249 ierr = NF_PUT_VARA_REAL(nid,sdid,start,size,sd2d) 250 #endif 251 if (ierr.ne.NF_NOERR) then 252 write (*,*) NF_STRERROR(ierr) 253 stop "" 254 endif 255 256 endif 257 258 ierr= NF_CLOSE(nid) 259 260 end subroutine wstats 261 262 !====================================================== 263 subroutine inivar(nid,varid,ngrid,dim,index,px,ierr) 264 265 implicit none 266 267 include "dimensions.h" 268 include "dimphys.h" 269 include "netcdf.inc" 270 271 integer, intent(in) :: nid,varid,dim,index,ngrid 272 real, dimension(ngrid,llm), intent(in) :: px 273 integer, intent(out) :: ierr 274 275 integer,parameter :: iip1=iim+1 276 integer,parameter :: jjp1=jjm+1 277 278 integer :: l,i,j,ig0 279 integer, dimension(4) :: start,size 280 real, dimension(iip1,jjp1,llm) :: dx3 281 real, dimension(iip1,jjp1) :: dx2 282 283 if (dim.eq.3) then 284 285 start=(/1,1,1,index/) 286 size=(/iip1,jjp1,llm,1/) 287 288 ! Passage variable physique --> variable dynamique 289 290 DO l=1,llm 291 DO i=1,iip1 292 dx3(i,1,l)=px(1,l) 293 dx3(i,jjp1,l)=px(ngrid,l) 294 ENDDO 295 DO j=2,jjm 296 ig0= 1+(j-2)*iim 297 DO i=1,iim 298 dx3(i,j,l)=px(ig0+i,l) 299 ENDDO 300 dx3(iip1,j,l)=dx3(1,j,l) 301 ENDDO 302 ENDDO 303 304 #ifdef NC_DOUBLE 305 ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,size,dx3) 306 #else 307 ierr = NF_PUT_VARA_REAL(nid,varid,start,size,dx3) 308 #endif 309 310 else if (dim.eq.2) then 311 312 start=(/1,1,index,0/) 313 size=(/iip1,jjp1,1,0/) 314 315 ! Passage variable physique --> physique dynamique 316 317 DO i=1,iip1 318 dx2(i,1)=px(1,1) 319 dx2(i,jjp1)=px(ngrid,1) 320 ENDDO 321 DO j=2,jjm 322 ig0= 1+(j-2)*iim 323 DO i=1,iim 324 dx2(i,j)=px(ig0+i,1) 325 ENDDO 326 dx2(iip1,j)=dx2(1,j) 327 ENDDO 328 329 #ifdef NC_DOUBLE 330 ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,size,dx2) 331 #else 332 ierr = NF_PUT_VARA_REAL(nid,varid,start,size,dx2) 356 #ifdef NC_DOUBLE 357 ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx2) 358 #else 359 ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx2) 333 360 #endif 334 361 -
trunk/LMDZ.MARS/libf/phymars/xvik.F
r1087 r1130 19 19 #include "logic.h" 20 20 #include "temps.h" 21 #include "control.h"21 !#include "control.h" 22 22 #include "ener.h" 23 23 #include "description.h"
Note: See TracChangeset
for help on using the changeset viewer.