Ignore:
Timestamp:
Jul 19, 2024, 10:05:57 AM (2 months ago)
Author:
abarral
Message:

[continued & end] replace netcdf by lmdz_netcdf.F90 wrapper
"use netcdf" is now only used in lmdz_netcdf.F90 (except ecrad and obsolete/)
<include "netcdf.inc"> is now likewise only used in lmdz_netcdf.F90.

systematically specify explicitely <USE lmdz_netcdf, ONLY:> (probably left some missing, to correct later on)

Further replacement of nf_put_* by nf90_put_* (same for _get_)

[minor] replace deprecated boolean operators along the way

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phylmd/dyn1d/mod_1D_cases_read2.F90

    r4706 r5075  
    33!
    44MODULE mod_1D_cases_read2
    5 
     5  USE lmdz_netcdf, ONLY: nf90_get_var,nf_noerr,nf_inq_varid,nf_inq_dimlen,nf_strerror,nf_open,&
     6          nf_nowrite,nf_inq_dimid
    67!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    78  !Declarations specifiques au cas standard
     
    8182    implicit none
    8283
    83     INCLUDE "netcdf.inc"
    84 
    8584    INTEGER nid,rid,ierr
    8685    INTEGER ii,jj
     
    9089    ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
    9190    print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
    92     if (ierr.NE.NF_NOERR) then
     91    if (ierr/=NF_NOERR) then
    9392       write(*,*) 'ERROR: GROS Pb opening forcings nc file '
    9493       write(*,*) NF_STRERROR(ierr)
     
    9796    !.......................................................................
    9897    ierr=NF_INQ_DIMID(nid,'lat',rid)
    99     IF (ierr.NE.NF_NOERR) THEN
     98    IF (ierr/=NF_NOERR) THEN
    10099       print*, 'Oh probleme lecture dimension lat'
    101100    ENDIF
     
    104103    !.......................................................................
    105104    ierr=NF_INQ_DIMID(nid,'lon',rid)
    106     IF (ierr.NE.NF_NOERR) THEN
     105    IF (ierr/=NF_NOERR) THEN
    107106       print*, 'Oh probleme lecture dimension lon'
    108107    ENDIF
     
    111110    !.......................................................................
    112111    ierr=NF_INQ_DIMID(nid,'lev',rid)
    113     IF (ierr.NE.NF_NOERR) THEN
     112    IF (ierr/=NF_NOERR) THEN
    114113       print*, 'Oh probleme lecture dimension zz'
    115114    ENDIF
     
    120119    print*,'nid,rid',nid,rid
    121120    nt_cas=0
    122     IF (ierr.NE.NF_NOERR) THEN
     121    IF (ierr/=NF_NOERR) THEN
    123122       stop 'probleme lecture dimension sens'
    124123    ENDIF
     
    192191    implicit none
    193192
    194     INCLUDE "netcdf.inc"
    195 
    196193    INTEGER nid,rid,ierr
    197194    INTEGER ii,jj
     
    201198    ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
    202199    print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
    203     if (ierr.NE.NF_NOERR) then
     200    if (ierr/=NF_NOERR) then
    204201       write(*,*) 'ERROR: GROS Pb opening forcings nc file '
    205202       write(*,*) NF_STRERROR(ierr)
     
    208205    !.......................................................................
    209206    ierr=NF_INQ_DIMID(nid,'lat',rid)
    210     IF (ierr.NE.NF_NOERR) THEN
     207    IF (ierr/=NF_NOERR) THEN
    211208       print*, 'Oh probleme lecture dimension lat'
    212209    ENDIF
     
    215212    !.......................................................................
    216213    ierr=NF_INQ_DIMID(nid,'lon',rid)
    217     IF (ierr.NE.NF_NOERR) THEN
     214    IF (ierr/=NF_NOERR) THEN
    218215       print*, 'Oh probleme lecture dimension lon'
    219216    ENDIF
     
    222219    !.......................................................................
    223220    ierr=NF_INQ_DIMID(nid,'nlev',rid)
    224     IF (ierr.NE.NF_NOERR) THEN
     221    IF (ierr/=NF_NOERR) THEN
    225222       print*, 'Oh probleme lecture dimension nlev'
    226223    ENDIF
     
    230227    ierr=NF_INQ_DIMID(nid,'time',rid)
    231228    nt_cas=0
    232     IF (ierr.NE.NF_NOERR) THEN
     229    IF (ierr/=NF_NOERR) THEN
    233230       stop 'Oh probleme lecture dimension time'
    234231    ENDIF
     
    317314  !**********************************************************************************************
    318315  SUBROUTINE old_read_SCM_cas
    319     use netcdf, only: nf90_get_var
    320316    implicit none
    321317
    322     INCLUDE "netcdf.inc"
    323318    INCLUDE "date_cas.h"
    324319
     
    331326    ierr = NF_OPEN(fich_cas,NF_NOWRITE,nid)
    332327    print*,'fich_cas,NF_NOWRITE,nid ',fich_cas,NF_NOWRITE,nid
    333     if (ierr.NE.NF_NOERR) then
     328    if (ierr/=NF_NOERR) then
    334329       write(*,*) 'ERROR: GROS Pb opening forcings nc file '
    335330       write(*,*) NF_STRERROR(ierr)
     
    338333    !.......................................................................
    339334    ierr=NF_INQ_DIMID(nid,'lat',rid)
    340     IF (ierr.NE.NF_NOERR) THEN
     335    IF (ierr/=NF_NOERR) THEN
    341336       print*, 'Oh probleme lecture dimension lat'
    342337    ENDIF
     
    345340    !.......................................................................
    346341    ierr=NF_INQ_DIMID(nid,'lon',rid)
    347     IF (ierr.NE.NF_NOERR) THEN
     342    IF (ierr/=NF_NOERR) THEN
    348343       print*, 'Oh probleme lecture dimension lon'
    349344    ENDIF
     
    352347    !.......................................................................
    353348    ierr=NF_INQ_DIMID(nid,'lev',rid)
    354     IF (ierr.NE.NF_NOERR) THEN
     349    IF (ierr/=NF_NOERR) THEN
    355350       print*, 'Oh probleme lecture dimension nlev'
    356351    ENDIF
     
    364359    ierr=NF_INQ_DIMID(nid,'time',rid)
    365360    nt_cas=0
    366     IF (ierr.NE.NF_NOERR) THEN
     361    IF (ierr/=NF_NOERR) THEN
    367362       stop 'Oh probleme lecture dimension time'
    368363    ENDIF
     
    533528
    534529
    535 END MODULE mod_1D_cases_read2
    536530!=====================================================================
    537531subroutine read_cas2(nid,nlevel,ntime                          &
     
    541535
    542536  !program reading forcing of the case study
    543   use netcdf, only: nf90_get_var
    544537  implicit none
    545   INCLUDE "netcdf.inc"
    546538
    547539  integer ntime,nlevel
     
    589581  do i=1,nbvar3d
    590582     print *,'Dans read_cas2, on va lire ',var3didin(i),name_var(i)
    591      if(i.LE.35) then
     583     if(i<=35) then
    592584        ierr = NF90_GET_VAR(nid,var3didin(i),resul, count = [1, 1, nlevel, ntime])
    593585        print *,'Dans read_cas2, on a lu ',ierr,var3didin(i),name_var(i)
     
    658650
    659651  !program reading forcing of the case study
    660   use netcdf, only: nf90_get_var
    661652  implicit none
    662   INCLUDE "netcdf.inc"
    663653
    664654  integer ntime,nlevel
     
    711701     else
    712702        !-----------------------------------------------------------------------
    713         if(i.LE.4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
     703        if(i<=4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
    714704           ierr = NF90_GET_VAR(nid,var3didin(i),apbp, count = [1, 1, nlevel + 1])
    715705           print *,'read2_cas(apbp), on a lu ',i,name_var(i)
     
    719709           endif
    720710           !-----------------------------------------------------------------------
    721         else if(i.gt.4.and.i.LE.45) then   ! Lecture des variables en (time,nlevel,lat,lon)
     711        else if(i>4.and.i<=45) then   ! Lecture des variables en (time,nlevel,lat,lon)
    722712           ierr = NF90_GET_VAR(nid,var3didin(i),resul, count = [1, 1, nlevel, ntime])
    723713           print *,'read2_cas(resul), on a lu ',i,name_var(i)
     
    727717           endif
    728718           !-----------------------------------------------------------------------
    729         else if (i.gt.45.and.i.LE.51) then   ! Lecture des variables en (time,lat,lon)
     719        else if (i>45.and.i<=51) then   ! Lecture des variables en (time,lat,lon)
    730720           ierr = NF90_GET_VAR(nid,var3didin(i),resul2, count = [1, 1, ntime])
    731721           print *,'read2_cas(resul2), on a lu ',i,name_var(i)
     
    829819
    830820  !program reading forcing of the case study
    831   use netcdf, only: nf90_get_var
    832821  implicit none
    833   INCLUDE "netcdf.inc"
    834822
    835823  integer ntime,nlevel,k,t
     
    888876     else
    889877        !-----------------------------------------------------------------------
    890         if(i.LE.4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
     878        if(i<=4) then     ! Lecture des coord pression en (nlevelp1,lat,lon)
    891879           ierr = NF90_GET_VAR(nid,var3didin(i),apbp)
    892880           print *,'read2_cas(apbp), on a lu ',i,name_var(i)
     
    896884           endif
    897885           !-----------------------------------------------------------------------
    898         else if(i.gt.4.and.i.LE.12) then   ! Lecture des variables en (time,nlevel,lat,lon)
     886        else if(i>4.and.i<=12) then   ! Lecture des variables en (time,nlevel,lat,lon)
    899887           ierr = NF90_GET_VAR(nid,var3didin(i),resul1)
    900888           print *,'read2_cas(resul1), on a lu ',i,name_var(i)
     
    905893           print*,'Lecture de la variable #i ',i,name_var(i),minval(resul1),maxval(resul1)
    906894           !-----------------------------------------------------------------------
    907         else if(i.gt.12.and.i.LE.54) then   ! Lecture des variables en (time,nlevel,lat,lon)
     895        else if(i>12.and.i<=54) then   ! Lecture des variables en (time,nlevel,lat,lon)
    908896           ierr = NF90_GET_VAR(nid,var3didin(i),resul)
    909897           print *,'read2_cas(resul), on a lu ',i,name_var(i)
     
    914902           print*,'Lecture de la variable #i ',i,name_var(i),minval(resul),maxval(resul)
    915903           !-----------------------------------------------------------------------
    916         else if (i.gt.54.and.i.LE.65) then   ! Lecture des variables en (time,lat,lon)
     904        else if (i>54.and.i<=65) then   ! Lecture des variables en (time,lat,lon)
    917905           ierr = NF90_GET_VAR(nid,var3didin(i),resul2)
    918906           print *,'read2_cas(resul2), on a lu ',i,name_var(i)
     
    11481136
    11491137  it_cas1=INT(timeit/pdt_cas)+1
    1150   IF (it_cas1 .EQ. nt_cas) THEN
     1138  IF (it_cas1 == nt_cas) THEN
    11511139     it_cas2=it_cas1
    11521140  ELSE
     
    11571145  !print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
    11581146
    1159   if (it_cas1 .gt. nt_cas) then
     1147  if (it_cas1 > nt_cas) then
    11601148     write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
    11611149          ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
     
    11641152
    11651153  ! time interpolation:
    1166   IF (it_cas1 .EQ. it_cas2) THEN
     1154  IF (it_cas1 == it_cas2) THEN
    11671155     frac=0.
    11681156  ELSE
     
    13631351
    13641352  it_cas1=INT(timeit/pdt_cas)+1
    1365   IF (it_cas1 .EQ. nt_cas) THEN
     1353  IF (it_cas1 == nt_cas) THEN
    13661354     it_cas2=it_cas1
    13671355  ELSE
     
    13731361  !print *,'it_cas1,it_cas2,time_cas1,time_cas2=',it_cas1,it_cas2,time_cas1,time_cas2
    13741362
    1375   if (it_cas1 .gt. nt_cas) then
     1363  if (it_cas1 > nt_cas) then
    13761364     write(*,*) 'PB-stop: day, day_ju_ini_cas,it_cas1, it_cas2, timeit: '            &
    13771365          ,day,day_ju_ini_cas,it_cas1,it_cas2,timeit
     
    13801368
    13811369  ! time interpolation:
    1382   IF (it_cas1 .EQ. it_cas2) THEN
     1370  IF (it_cas1 == it_cas2) THEN
    13831371     frac=0.
    13841372  ELSE
     
    14751463!**********************************************************************************************
    14761464
     1465END MODULE mod_1D_cases_read2
Note: See TracChangeset for help on using the changeset viewer.