Ignore:
Timestamp:
Oct 5, 2021, 8:34:09 AM (3 years ago)
Author:
emillour
Message:

Mars GCM utilities:
Minor fixes to run with picky gfortran 10.3.0 which requires one element arrays
(rather than scalars) when calling NetCDF routines, andf that stop statements
should not be followed by strings. While at it replaced tabs with spaces.
EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/util/streamfunction.F90

    r2513 r2567  
    129129if (ierr.ne.NF_NOERR) then
    130130   write(*,*) 'ERROR: Pb opening input file'
    131    stop ""
     131   stop
    132132endif
    133133
     
    143143ierr=NF_INQ_DIMID(infid,"latitude",tmpdimid)
    144144if (ierr.ne.NF_NOERR) then
    145   stop "Error: Failed to get latitude dimension ID"
     145  write(*,*) "Error: Failed to get latitude dimension ID"
     146  stop
    146147else
    147148  ierr=NF_INQ_VARID(infid,"latitude",tmpvarid)
    148149  if (ierr.ne.NF_NOERR) then
    149     stop "Error: Failed to get latitude ID"
     150    write(*,*) "Error: Failed to get latitude ID"
     151    stop
    150152  else
    151153    ierr=NF_INQ_DIMLEN(infid,tmpdimid,latlength)
    152154    if (ierr.ne.NF_NOERR) then
    153       stop "Error: Failed to get latitude length"
     155      write(*,*) "Error: Failed to get latitude length"
     156      stop
    154157    else
    155158      allocate(lat(latlength))
    156159      ierr=NF_GET_VAR_REAL(infid,tmpvarid,lat)
    157160      if (ierr.ne.NF_NOERR) then
    158         stop "Error: Failed reading latitude"
     161        write(*,*) "Error: Failed reading latitude"
     162        stop
    159163      endif
    160164    endif
     
    165169ierr=NF_INQ_DIMID(infid,"longitude",tmpdimid)
    166170if (ierr.ne.NF_NOERR) then
    167   stop "Error: Failed to get longitude dimension ID"
     171  write(*,*) "Error: Failed to get longitude dimension ID"
     172  stop
    168173else
    169174  ierr=NF_INQ_VARID(infid,"longitude",tmpvarid)
    170175  if (ierr.ne.NF_NOERR) then
    171     stop "Error: Failed to get longitude ID"
     176    write(*,*) "Error: Failed to get longitude ID"
     177    stop
    172178  else
    173179    ierr=NF_INQ_DIMLEN(infid,tmpdimid,lonlength)
    174180    if (ierr.ne.NF_NOERR) then
    175       stop "Error: Failed to get longitude length"
     181      write(*,*) "Error: Failed to get longitude length"
     182      stop
    176183    else
    177184      allocate(lon(lonlength))
    178185      ierr=NF_GET_VAR_REAL(infid,tmpvarid,lon)
    179186      if (ierr.ne.NF_NOERR) then
    180         stop "Error: Failed reading longitude"
     187        write(*,*) "Error: Failed reading longitude"
     188        stop
    181189      endif
    182190    endif
     
    187195ierr=NF_INQ_DIMID(infid,"Time",tmpdimid)
    188196if (ierr.ne.NF_NOERR) then
    189   stop "Error: Failed to get Time dimension ID"
     197  write(*,*) "Error: Failed to get Time dimension ID"
     198  stop
    190199else
    191200  ierr=NF_INQ_VARID(infid,"Time",tmpvarid)
    192201  if (ierr.ne.NF_NOERR) then
    193     stop "Error: Failed to get Time ID"
     202    write(*,*) "Error: Failed to get Time ID"
     203    stop
    194204  else
    195205    ierr=NF_INQ_DIMLEN(infid,tmpdimid,timelength)
    196206    if (ierr.ne.NF_NOERR) then
    197       stop "Error: Failed to get Time length"
     207      write(*,*) "Error: Failed to get Time length"
     208      stop
    198209    else
    199210      allocate(time(timelength))
    200211      ierr=NF_GET_VAR_REAL(infid,tmpvarid,time)
    201212      if (ierr.ne.NF_NOERR) then
    202         stop "Error: Failed reading Time"
     213        write(*,*) "Error: Failed reading Time"
     214        stop
    203215      endif
    204216    endif
     
    209221ierr=NF_INQ_DIMID(infid,"altitude",tmpdimid)
    210222if (ierr.ne.NF_NOERR) then
    211   stop "Error: Failed to get altitude dimension ID"
     223  write(*,*) "Error: Failed to get altitude dimension ID"
     224  stop
    212225else
    213226  ierr=NF_INQ_VARID(infid,"altitude",tmpvarid)
    214227  if (ierr.ne.NF_NOERR) then
    215      stop "Error: Failed to get altitude length"
     228     write(*,*) "Error: Failed to get altitude length"
     229     stop
    216230  else
    217231     ierr=NF_INQ_DIMLEN(infid,tmpdimid,altlength)
    218232     if (ierr.ne.NF_NOERR) then
    219         stop "Error: Failed to get altitude length"
     233        write(*,*) "Error: Failed to get altitude length"
     234        stop
    220235     else   
    221236        allocate(alt(altlength))
    222237        ierr=NF_GET_VAR_REAL(infid,tmpvarid,alt)
    223238        if (ierr.ne.NF_NOERR) then
    224            stop "Error: Failed reading Altitude"
     239           write(*,*) "Error: Failed reading Altitude"
     240           stop
    225241        endif
    226242     endif
     
    235251ierr=NF_INQ_VARID(infid,"aps",tmpvarid)
    236252if (ierr.ne.NF_NOERR) then
    237    stop "Error: Failed to get aps ID"
     253   write(*,*) "Error: Failed to get aps ID"
     254   stop
    238255else
    239256   allocate(aps(altlength))
    240257   ierr=NF_GET_VAR_REAL(infid,tmpvarid,aps)
    241258   if (ierr.ne.NF_NOERR) then
    242       stop "Error: Failed reading aps"
     259      write(*,*) "Error: Failed reading aps"
     260      stop
    243261   endif
    244262endif
     
    247265ierr=NF_INQ_VARID(infid,"bps",tmpvarid)
    248266if (ierr.ne.NF_NOERR) then
    249    stop "Error: Failed to get bps ID"
     267   write(*,*) "Error: Failed to get bps ID"
     268   stop
    250269else
    251270   allocate(bps(altlength))
    252271   ierr=NF_GET_VAR_REAL(infid,tmpvarid,bps)
    253272   if (ierr.ne.NF_NOERR) then
    254       stop "Error: Failed reading bps"
     273      write(*,*) "Error: Failed reading bps"
     274      stop
    255275   endif
    256276endif
     
    259279ierr=NF_INQ_VARID(infid,"ps",tmpvarid)
    260280if (ierr.ne.NF_NOERR) then
    261    stop "Error: Failed to get ps ID"
     281   write(*,*) "Error: Failed to get ps ID"
     282   stop
    262283else
    263284   allocate(ps(lonlength,latlength,timelength))
    264285   ierr=NF_GET_VAR_REAL(infid,tmpvarid,ps)
    265286   if (ierr.ne.NF_NOERR) then
    266       stop "Error: Failed reading ps"
     287      write(*,*) "Error: Failed reading ps"
     288      stop
    267289   endif
    268290endif
     
    284306ierr=NF_INQ_VARID(infid,"u",tmpvarid)
    285307if (ierr.ne.NF_NOERR) then
    286   stop "Error: Failed to get u ID"
     308  write(*,*) "Error: Failed to get u ID"
     309  stop
    287310else
    288311  allocate(u(lonlength,latlength,altlength,timelength))
    289312  ierr=NF_GET_VAR_REAL(infid,tmpvarid,u)
    290313  if (ierr.ne.NF_NOERR) then
    291     stop "Error: Failed reading zonal wind"
     314    write(*,*) "Error: Failed reading zonal wind"
     315    stop
    292316  endif
    293317endif
     
    296320ierr=NF_INQ_VARID(infid,"v",tmpvarid)
    297321if (ierr.ne.NF_NOERR) then
    298   stop "Error: Failed to get v ID"
     322  write(*,*) "Error: Failed to get v ID"
     323  stop
    299324else
    300325  allocate(v(lonlength,latlength,altlength,timelength))
    301326  ierr=NF_GET_VAR_REAL(infid,tmpvarid,v)
    302327  if (ierr.ne.NF_NOERR) then
    303     stop "Error: Failed reading zonal wind"
     328    write(*,*) "Error: Failed reading zonal wind"
     329    stop
    304330  endif
    305331endif
     
    322348     if (ierr.ne.NF_NOERR) then
    323349        write(*,*) "Problem: Could not find/open these files"
    324         stop "Might as well stop here"
     350        write(*,*) "Might as well stop here"
     351        stop
    325352     endif
    326353  endif
     
    329356   ierr=NF_INQ_VARID(infid2,"aire",tmpvarid)
    330357   if (ierr.ne.NF_NOERR) then
    331       stop "Error: Failed to get aire ID"
     358      write(*,*) "Error: Failed to get aire ID"
     359      stop
    332360   endif
    333361   ! Get aire
    334362   ierr=NF_GET_VAR_REAL(infid2,tmpvarid,aire)
    335363   if (ierr.ne.NF_NOERR) then
    336       stop "Error: Failed reading aire"
     364      write(*,*) "Error: Failed reading aire"
     365      stop
    337366   endif
    338367   ! Close file
     
    342371   ierr=NF_GET_VAR_REAL(infid,tmpvarid,aire)
    343372   if (ierr.ne.NF_NOERR) then
    344       stop "Error: Failed reading aire"
     373      write(*,*) "Error: Failed reading aire"
     374      stop
    345375   endif
    346376endif
     
    363393     if (ierr.ne.NF_NOERR) then
    364394        write(*,*) "Problem: Could not find/open these files"
    365         stop "Might as well stop here"
     395        write(*,*) "Might as well stop here"
     396        stop
    366397     endif
    367398  endif
     
    371402   ierr=NF_INQ_VARID(infid2,"phisinit",tmpvarid)
    372403   if (ierr.ne.NF_NOERR) then
    373       stop "Error: Failed to get phisinit ID"
     404      write(*,*) "Error: Failed to get phisinit ID"
     405      stop
    374406   endif
    375407   ! Get phisinit
    376408   ierr=NF_GET_VAR_REAL(infid2,tmpvarid,phisinit)
    377409   if (ierr.ne.NF_NOERR) then
    378       stop "Error: Failed reading phisinit"
     410      write(*,*) "Error: Failed reading phisinit"
     411      stop
    379412   endif
    380413   ! Close file
     
    384417   ierr=NF_GET_VAR_REAL(infid,tmpvarid,phisinit)
    385418   if (ierr.ne.NF_NOERR) then
    386       stop "Error: Failed reading phisinit"
     419      write(*,*) "Error: Failed reading phisinit"
     420      stop
    387421   endif
    388422endif
     
    407441     if (ierr.ne.NF_NOERR) then
    408442        write(*,*) "Problem: Could not find/open these files"
    409         stop "Might as well stop here"
     443        write(*,*) "Might as well stop here"
     444        stop
    410445     endif
    411446  endif
     
    415450   ierr=NF_INQ_VARID(infid2,"cv",tmpvarid)
    416451   if (ierr.ne.NF_NOERR) then
    417       stop "Error: Failed to get cv ID"
     452      write(*,*) "Error: Failed to get cv ID"
     453      stop
    418454   endif
    419455   ! Get cv
    420456   ierr=NF_GET_VAR_REAL(infid2,tmpvarid,cv)
    421457   if (ierr.ne.NF_NOERR) then
    422       stop "Error: Failed reading cv"
     458      write(*,*) "Error: Failed reading cv"
     459      stop
    423460   endif
    424461   ! Close file
     
    428465   ierr=NF_GET_VAR_REAL(infid,tmpvarid,cv)
    429466   if (ierr.ne.NF_NOERR) then
    430       stop "Error: Failed reading cv"
     467      write(*,*) "Error: Failed reading cv"
     468      stop
    431469   endif
    432470endif
     
    436474ierr=NF_INQ_VARID(infid,"temp",tmpvarid)
    437475if (ierr.ne.NF_NOERR) then
    438   stop "Error: Failed to get temp ID"
     476  write(*,*) "Error: Failed to get temp ID"
     477  stop
    439478else
    440479  allocate(temp(lonlength,latlength,altlength,timelength))
    441480  ierr=NF_GET_VAR_REAL(infid,tmpvarid,temp)
    442481  if (ierr.ne.NF_NOERR) then
    443     stop "Error: Failed reading temperature"
     482    write(*,*) "Error: Failed reading temperature"
     483    stop
    444484  endif
    445485endif
     
    464504  ierr=NF_GET_VAR_REAL(infid,tmpvarid,rho)
    465505  if (ierr.ne.NF_NOERR) then
    466     stop "Error: Failed reading mass density"
     506    write(*,*) "Error: Failed reading mass density"
     507    stop
    467508  endif
    468509endif
     
    666707lon_fake(1)=0.
    667708#ifdef NC_DOUBLE
    668         ierr= NF_PUT_VARA_DOUBLE(nout,lonvarout,1,1,lon_fake)
     709        ierr= NF_PUT_VARA_DOUBLE(nout,lonvarout,(/1/),(/1/),lon_fake)
    669710#else
    670         ierr= NF_PUT_VARA_REAL(nout,lonvarout,1,1,lon_fake)
     711        ierr= NF_PUT_VARA_REAL(nout,lonvarout,(/1/),(/1/),lon_fake)
    671712#endif
    672713
    673714! 3.1.3 New time dimension/value in output file
    674715#ifdef NC_DOUBLE
    675         ierr= NF_PUT_VARA_DOUBLE(nout,timevarout,1,1,lon_fake)
     716        ierr= NF_PUT_VARA_DOUBLE(nout,timevarout,(/1/),(/1/),lon_fake)
    676717#else
    677         ierr= NF_PUT_VARA_REAL(nout,timevarout,1,1,lon_fake)
     718        ierr= NF_PUT_VARA_REAL(nout,timevarout,(/1/),(/1/),lon_fake)
    678719#endif
    679720
     
    690731if (ierr.ne.NF_NOERR) then
    691732   write(*,*) 'Error, could not define variable psi'
    692    stop ""
     733   stop
    693734endif
    694735
     
    705746if (ierr.ne.NF_NOERR) then
    706747   write(*,*) 'Error, could not define variable momave'
    707    stop ""
     748   stop
    708749endif
    709750
     
    721762if (ierr.ne.NF_NOERR) then
    722763   write(*,*) 'Error, could not define variable u'
    723    stop ""
     764   stop
    724765endif
    725766
     
    737778if (ierr.ne.NF_NOERR) then
    738779   write(*,*) 'Error, could not define variable v'
    739    stop ""
     780   stop
    740781endif
    741782
     
    752793if (ierr.ne.NF_NOERR) then
    753794   write(*,*) 'Error, could not define variable rho'
    754    stop ""
     795   stop
    755796endif
    756797
     
    767808if (ierr.ne.NF_NOERR) then
    768809   write(*,*) 'Error, could not define variable temp'
    769    stop ""
     810   stop
    770811endif
    771812
     
    782823if (ierr.ne.NF_NOERR) then
    783824   write(*,*) 'Error, could not define variable ps'
    784    stop ""
     825   stop
    785826endif
    786827
     
    798839if (ierr.ne.NF_NOERR) then
    799840   write(*,*) 'Error, could not define variable phisinit'
    800    stop ""
     841   stop
    801842endif
    802843
     
    874915if (ierr.NE.NF_NOERR) then
    875916   WRITE(*,*)'ERROR: Impossible to create the file.'
    876    stop ""
     917   stop
    877918endif
    878919
     
    9831024  ierr=NF_GET_VAR_REAL(infid,tmpvarid,aps)
    9841025  if (ierr.ne.NF_NOERR) then
    985    stop "error: Failed reading aps"
     1026   write(*,*) "error: Failed reading aps"
     1027   stop
    9861028  endif
    9871029  aps_ok=.true.
     
    9971039  ierr=NF_GET_VAR_REAL(infid,tmpvarid,bps)
    9981040  if (ierr.ne.NF_NOERR) then
    999     stop "Error: Failed reading bps"
     1041    write(*,*) "Error: Failed reading bps"
     1042    stop
    10001043  endif
    10011044  bps_ok=.true.
     
    10151058        (/altdimout/),apsid,ierr)
    10161059   if (ierr.ne.NF_NOERR) then
    1017       stop "Error: Failed to def_var aps"
     1060      write(*,*) "Error: Failed to def_var aps"
     1061      stop
    10181062   endif
    10191063
     
    10251069#endif
    10261070   if (ierr.ne.NF_NOERR) then
    1027       stop "Error: Failed to write aps"
     1071      write(*,*) "Error: Failed to write aps"
     1072      stop
    10281073   endif
    10291074ENDIF
     
    10341079        (/altdimout/),bpsid,ierr)
    10351080   if (ierr.ne.NF_NOERR) then
    1036       stop "Error: Failed to def_var bps"
     1081      write(*,*) "Error: Failed to def_var bps"
     1082      stop
    10371083   endif
    10381084
     
    10441090#endif
    10451091   if (ierr.ne.NF_NOERR) then
    1046       stop "Error: Failed to write bps"
     1092      write(*,*) "Error: Failed to write bps"
     1093      stop
    10471094   endif
    10481095ENDIF
Note: See TracChangeset for help on using the changeset viewer.