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/hrecast.F90

    r2140 r2567  
    116116if (ierr.ne.NF_NOERR) then
    117117   write(*,*) 'ERROR: Pb opening file ',trim(infile)
    118    stop ""
     118   stop
    119119endif
    120120
     
    189189  write(*,*) 'No variables to process !?'
    190190  write(*,*) 'Might as well stop here'
    191   stop ""
     191  stop
    192192else
    193193  write(*,*) ""
     
    209209ierr=NF_INQ_DIMID(infid,"latitude",tmpdimid)
    210210if (ierr.ne.NF_NOERR) then
    211   stop "Error: Failed to get latitude dimension ID"
     211  write(*,*) "Error: Failed to get latitude dimension ID"
     212  stop
    212213else
    213214  ierr=NF_INQ_VARID(infid,"latitude",tmpvarid)
    214215  if (ierr.ne.NF_NOERR) then
    215     stop "Error: Failed to get latitude ID"
     216    write(*,*) "Error: Failed to get latitude ID"
     217    stop
    216218  else
    217219    ierr=NF_INQ_DIMLEN(infid,tmpdimid,inlatlength)
    218220    if (ierr.ne.NF_NOERR) then
    219       stop "Error: Failed to get latitude length"
     221      write(*,*) "Error: Failed to get latitude length"
     222      stop
    220223    else
    221224      allocate(inlat(inlatlength))
    222225      ierr=NF_GET_VAR_REAL(infid,tmpvarid,inlat)
    223226      if (ierr.ne.NF_NOERR) then
    224         stop "Error: Failed reading latitude"
     227        write(*,*) "Error: Failed reading latitude"
     228        stop
    225229      endif
    226230    endif
     
    244248ierr=NF_INQ_DIMID(infid,"longitude",tmpdimid)
    245249if (ierr.ne.NF_NOERR) then
    246   stop "Error: Failed to get longitude dimension ID"
     250  write(*,*) "Error: Failed to get longitude dimension ID"
     251  stop
    247252else
    248253  ierr=NF_INQ_VARID(infid,"longitude",tmpvarid)
    249254  if (ierr.ne.NF_NOERR) then
    250     stop "Error: Failed to get longitude ID"
     255    write(*,*) "Error: Failed to get longitude ID"
     256    stop
    251257  else
    252258    ierr=NF_INQ_DIMLEN(infid,tmpdimid,inlonlength)
    253259    if (ierr.ne.NF_NOERR) then
    254       stop "Error: Failed to get longitude length"
     260      write(*,*) "Error: Failed to get longitude length"
     261      stop
    255262    else
    256263      allocate(inlon(inlonlength))
    257264      ierr=NF_GET_VAR_REAL(infid,tmpvarid,inlon)
    258265      if (ierr.ne.NF_NOERR) then
    259         stop "Error: Failed reading longitude"
     266        write(*,*) "Error: Failed reading longitude"
     267        stop
    260268      endif
    261269    endif
     
    279287ierr=NF_INQ_DIMID(infid,"altitude",tmpdimid)
    280288if (ierr.ne.NF_NOERR) then
    281   stop "Error: Failed to get altitude dimension ID"
     289  write(*,*) "Error: Failed to get altitude dimension ID"
     290  stop
    282291else
    283292  ierr=NF_INQ_VARID(infid,"altitude",tmpvarid)
    284293  if (ierr.ne.NF_NOERR) then
    285     stop "Error: Failed to get altitude ID"
     294    write(*,*) "Error: Failed to get altitude ID"
     295    stop
    286296  else
    287297    ierr=NF_INQ_DIMLEN(infid,tmpdimid,altlength)
    288298    if (ierr.ne.NF_NOERR) then
    289       stop "Error: Failed to get altitude length"
     299      write(*,*) "Error: Failed to get altitude length"
     300      stop
    290301    else
    291302      allocate(alt(altlength))
    292303      ierr=NF_GET_VAR_REAL(infid,tmpvarid,alt)
    293304      if (ierr.ne.NF_NOERR) then
    294         stop "Error: Failed reading altitude"
     305        write(*,*) "Error: Failed reading altitude"
     306        stop
    295307      endif
    296308    endif
     
    301313ierr=NF_INQ_DIMID(infid,"Time",tmpdimid)
    302314if (ierr.ne.NF_NOERR) then
    303   stop "Error: Failed to get Time dimension ID"
     315  write(*,*) "Error: Failed to get Time dimension ID"
     316  stop
    304317else
    305318  ierr=NF_INQ_VARID(infid,"Time",tmpvarid)
    306319  if (ierr.ne.NF_NOERR) then
    307     stop "Error: Failed to get Time ID"
     320    write(*,*) "Error: Failed to get Time ID"
     321    stop
    308322  else
    309323    ierr=NF_INQ_DIMLEN(infid,tmpdimid,timelength)
    310324    if (ierr.ne.NF_NOERR) then
    311       stop "Error: Failed to get Time length"
     325      write(*,*) "Error: Failed to get Time length"
     326      stop
    312327    else
    313328      allocate(time(timelength))
    314329      ierr=NF_GET_VAR_REAL(infid,tmpvarid,time)
    315330      if (ierr.ne.NF_NOERR) then
    316         stop "Error: Failed reading Time"
     331        write(*,*) "Error: Failed reading Time"
     332        stop
    317333      endif
    318334    endif
     
    332348  ierr=NF_GET_VAR_REAL(infid,tmpvarid,sigma)
    333349  if (ierr.ne.NF_NOERR) then
    334     stop "Error: Failed reading sigma"
     350    write(*,*) "Error: Failed reading sigma"
     351    stop
    335352  endif
    336353endif
     
    341358  ierr=NF_INQ_VARID(infid,"aps",tmpvarid)
    342359  if (ierr.ne.NF_NOERR) then
    343     stop "Error: Failed to get aps ID"
     360    write(*,*) "Error: Failed to get aps ID"
     361    stop
    344362  else
    345363    allocate(aps(altlength))
    346364    ierr=NF_GET_VAR_REAL(infid,tmpvarid,aps)
    347365    if (ierr.ne.NF_NOERR) then
    348       stop "Error: Failed reading aps"
     366      write(*,*) "Error: Failed reading aps"
     367      stop
    349368    endif
    350369  endif
     
    353372  ierr=NF_INQ_VARID(infid,"bps",tmpvarid)
    354373  if (ierr.ne.NF_NOERR) then
    355     stop "Error: Failed to get bps ID"
     374    write(*,*) "Error: Failed to get bps ID"
     375    stop
    356376  else
    357377    allocate(bps(altlength))
    358378    ierr=NF_GET_VAR_REAL(infid,tmpvarid,bps)
    359379    if (ierr.ne.NF_NOERR) then
    360       stop "Error: Failed reading bps"
     380      write(*,*) "Error: Failed reading bps"
     381      stop
    361382    endif
    362383  endif
     
    377398  ierr=NF_GET_VAR_REAL(infid,tmpvarid,inphisinit)
    378399  if (ierr.ne.NF_NOERR) then
    379     stop "Error: Failed reading phisinit"
     400    write(*,*) "Error: Failed reading phisinit"
     401    stop
    380402  endif
    381403endif
     
    525547ierr=NF_DEF_DIM(outfid,"longitude",lonlength,lon_dimid)
    526548if (ierr.ne.NF_NOERR) then
    527   stop "Error: Could not define longitude dimension"
     549  write(*,*) "Error: Could not define longitude dimension"
     550  stop
    528551endif
    529552
     
    531554ierr=NF_DEF_DIM(outfid,"latitude",latlength,lat_dimid)
    532555if (ierr.ne.NF_NOERR) then
    533   stop "Error: Could not define latitude dimension"
     556  write(*,*) "Error: Could not define latitude dimension"
     557  stop
    534558endif
    535559
     
    537561ierr=NF_DEF_DIM(outfid,"altitude",altlength,alt_dimid)
    538562if (ierr.ne.NF_NOERR) then
    539   stop "Error: Could not define altitude dimension"
     563  write(*,*) "Error: Could not define altitude dimension"
     564  stop
    540565endif
    541566
     
    543568ierr=NF_DEF_DIM(outfid,"Time",NF_UNLIMITED,time_dimid)
    544569if (ierr.ne.NF_NOERR) then
    545   stop "Error: Could not define latitude dimension"
     570  write(*,*) "Error: Could not define latitude dimension"
     571  stop
    546572endif
    547573
     
    556582ierr=NF_DEF_VAR(outfid,"longitude",NF_REAL,1,datashape(1),lon_varid)
    557583if (ierr.ne.NF_NOERR) then
    558   stop "Error: Could not define longitude variable"
     584  write(*,*) "Error: Could not define longitude variable"
     585  stop
    559586endif
    560587
     
    563590ierr=NF_PUT_ATT_TEXT(outfid,lon_varid,'long_name',len_trim(text),text)
    564591if (ierr.ne.NF_NOERR) then
    565   stop "Error: Problem writing long_name for longitude"
     592  write(*,*) "Error: Problem writing long_name for longitude"
     593  stop
    566594endif
    567595text='degrees_east'
    568596ierr=NF_PUT_ATT_TEXT(outfid,lon_varid,'units',len_trim(text),text)
    569597if (ierr.ne.NF_NOERR) then
    570   stop "Error: Problem writing units for longitude"
     598  write(*,*) "Error: Problem writing units for longitude"
     599  stop
    571600endif
    572601
     
    575604ierr=NF_DEF_VAR(outfid,"latitude",NF_REAL,1,datashape(2),lat_varid)
    576605if (ierr.ne.NF_NOERR) then
    577   stop "Error: Could not define latitude variable"
     606  write(*,*) "Error: Could not define latitude variable"
     607  stop
    578608endif
    579609
     
    582612ierr=NF_PUT_ATT_TEXT(outfid,lat_varid,'long_name',len_trim(text),text)
    583613if (ierr.ne.NF_NOERR) then
    584   stop "Error: Problem writing long_name for latitude"
     614  write(*,*) "Error: Problem writing long_name for latitude"
     615  stop
    585616endif
    586617text='degrees_north'
    587618ierr=NF_PUT_ATT_TEXT(outfid,lat_varid,'units',len_trim(text),text)
    588619if (ierr.ne.NF_NOERR) then
    589   stop "Error: Problem writing units for latitude"
     620  write(*,*) "Error: Problem writing units for latitude"
     621  stop
    590622endif
    591623
     
    594626ierr=NF_DEF_VAR(outfid,"altitude",NF_REAL,1,datashape(3),alt_varid)
    595627if (ierr.ne.NF_NOERR) then
    596   stop "Error: Could not define altitude variable"
     628  write(*,*) "Error: Could not define altitude variable"
     629  stop
    597630endif
    598631
     
    629662  ierr=NF_DEF_VAR(outfid,"sigma",NF_REAL,1,alt_dimid,sigma_varid)
    630663  if (ierr.ne.NF_NOERR) then
    631     stop "Error: Could not define sigma variable"
     664    write(*,*) "Error: Could not define sigma variable"
     665    stop
    632666  endif
    633667else ! hybrid coordinates
    634668  ierr=NF_DEF_VAR(outfid,"aps",NF_REAL,1,alt_dimid,aps_varid)
    635669  if (ierr.ne.NF_NOERR) then
    636     stop "Error: Could not define aps variable"
     670    write(*,*) "Error: Could not define aps variable"
     671    stop
    637672  endif
    638673  ierr=NF_DEF_VAR(outfid,"bps",NF_REAL,1,alt_dimid,bps_varid)
    639674  if (ierr.ne.NF_NOERR) then
    640     stop "Error: Could not define bps variable"
     675    write(*,*) "Error: Could not define bps variable"
     676    stop
    641677  endif
    642678endif
     
    647683  ierr=NF_PUT_ATT_TEXT(outfid,sigma_varid,'long_name',len_trim(text),text)
    648684  if (ierr.ne.NF_NOERR) then
    649     stop "Error: Problem writing long_name for sigma"
     685    write(*,*) "Error: Problem writing long_name for sigma"
     686    stop
    650687  endif
    651688else ! hybrid coordinates
     
    653690  ierr=NF_PUT_ATT_TEXT(outfid,aps_varid,'long_name',len_trim(text),text)
    654691  if (ierr.ne.NF_NOERR) then
    655     stop "Error: Problem writing long_name for aps"
     692    write(*,*) "Error: Problem writing long_name for aps"
     693    stop
    656694  endif
    657695  text="hybrid sigma at midlayers"
    658696  ierr=NF_PUT_ATT_TEXT(outfid,bps_varid,'long_name',len_trim(text),text)
    659697  if (ierr.ne.NF_NOERR) then
    660     stop "Error: Problem writing long_name for bps"
     698    write(*,*) "Error: Problem writing long_name for bps"
     699    stop
    661700  endif
    662701endif ! of if (have_sigma)
     
    666705ierr=NF_DEF_VAR(outfid,"Time",NF_REAL,1,datashape(4),time_varid)
    667706if (ierr.ne.NF_NOERR) then
    668   stop "Error: Could not define Time variable"
     707  write(*,*) "Error: Could not define Time variable"
     708  stop
    669709endif
    670710
     
    683723  ierr=NF_PUT_ATT_TEXT(outfid,time_varid,'units',len_trim(text),text)
    684724  if (ierr.ne.NF_NOERR) then
    685     stop "Error: Problem writing units for Time"
     725    write(*,*) "Error: Problem writing units for Time"
     726    stop
    686727  endif
    687728endif
     
    694735    ierr=NF_DEF_VAR(outfid,"phisinit",NF_REAL,2,datashape,phisinit_varid)
    695736    if (ierr.ne.NF_NOERR) then
    696       stop "Error: Could not define phisinit variable"
     737      write(*,*) "Error: Could not define phisinit variable"
     738      stop
    697739    endif
    698740  endif
     
    701743  ierr=NF_PUT_ATT_TEXT(outfid,phisinit_varid,'long_name',len_trim(text),text)
    702744  if (ierr.ne.NF_NOERR) then
    703     stop "Error: Problem writing long_name for phisinit"
     745    write(*,*) "Error: Problem writing long_name for phisinit"
     746    stop
    704747  endif
    705748endif ! of if (have_geopot)
     
    714757  if (ierr.ne.NF_NOERR) then
    715758    write(*,*) 'Error, failed to get ID for input variable ',trim(var(i))
    716     stop ""
     759    stop
    717760  endif
    718761 
     
    738781  if (ierr.ne.NF_NOERR) then
    739782    write(*,*) 'Error, could not define variable ',trim(var(i))
    740     stop ""
     783    stop
    741784  endif
    742785 
     
    747790    write(*,*) 'Error, could not get number of attributes for variable ',&
    748791               trim(var(i))
    749     stop ""
     792    stop
    750793  endif
    751794  ! inititialize j == number of attributes written to output
     
    766809      if (ierr.ne.NF_NOERR) then
    767810        write(*,*) "Error failed to copy title attribute:",trim(text)
    768       stop ""
     811        stop
    769812      endif
    770813    endif
     
    775818    if (ierr.ne.NF_NOERR) then
    776819      write(*,*) "Error failed to copy long_name attribute:",trim(text)
    777       stop ""
     820      stop
    778821    endif
    779822  endif
     
    789832    if (ierr.ne.NF_NOERR) then
    790833      write(*,*) "Error failed to copy units attribute:",trim(text)
    791       stop ""
     834      stop
    792835    endif
    793836  endif
     
    805848  ierr=NF_PUT_ATT_REAL(outfid,var_id(i),'missing_value',NF_REAL,1,miss_val)
    806849  if (ierr.ne.NF_NOERR) then
    807     stop "Error, failed to write missing_value attribute"
     850    write(*,*) "Error, failed to write missing_value attribute"
     851    stop
    808852  endif
    809853 
     
    823867ierr=NF_ENDDEF(outfid)
    824868if (ierr.ne.NF_NOERR) then
    825   stop "Error: Could not switch out of define mode"
     869  write(*,*) "Error: Could not switch out of define mode"
     870  stop
    826871endif
    827872
     
    829874ierr=NF_PUT_VAR_REAL(outfid,lon_varid,lon)
    830875if (ierr.ne.NF_NOERR) then
    831   stop "Error: Could not write longitude data to output file"
     876  write(*,*) "Error: Could not write longitude data to output file"
     877  stop
    832878endif
    833879
     
    835881ierr=NF_PUT_VAR_REAL(outfid,lat_varid,lat)
    836882if (ierr.ne.NF_NOERR) then
    837   stop "Error: Could not write latitude data to output file"
     883  write(*,*) "Error: Could not write latitude data to output file"
     884  stop
    838885endif
    839886
     
    841888ierr=NF_PUT_VAR_REAL(outfid,alt_varid,alt)
    842889if (ierr.ne.NF_NOERR) then
    843   stop "Error: Could not write altitude data to output file"
     890  write(*,*) "Error: Could not write altitude data to output file"
     891  stop
    844892endif
    845893
     
    848896  ierr=NF_PUT_VAR_REAL(outfid,sigma_varid,sigma)
    849897  if (ierr.ne.NF_NOERR) then
    850     stop "Error: Could not write sigma data to output file"
     898    write(*,*) "Error: Could not write sigma data to output file"
     899    stop
    851900  endif
    852901else ! hybrid coordinates
    853902  ierr=NF_PUT_VAR_REAL(outfid,aps_varid,aps)
    854903  if (ierr.ne.NF_NOERR) then
    855     stop "Error: Could not write aps data to output file"
     904    write(*,*) "Error: Could not write aps data to output file"
     905    stop
    856906  endif
    857907  ierr=NF_PUT_VAR_REAL(outfid,bps_varid,bps)
    858908  if (ierr.ne.NF_NOERR) then
    859     stop "Error: Could not write bps data to output file"
     909    write(*,*) "Error: Could not write bps data to output file"
     910    stop
    860911  endif
    861912endif
    862913
    863914! write time
    864 ierr=NF_PUT_VARA_REAL(outfid,time_varid,1,timelength,time)
    865 if (ierr.ne.NF_NOERR) then
    866   stop "Error: Could not write Time data to output file"
     915ierr=NF_PUT_VARA_REAL(outfid,time_varid,(/1/),(/timelength/),time)
     916if (ierr.ne.NF_NOERR) then
     917  write(*,*) "Error: Could not write Time data to output file"
     918  stop
    867919endif
    868920
     
    880932  ierr=NF_INQ_VARID(infid,"phisinit",tmpvarid)
    881933  if (ierr.ne.NF_NOERR) then
    882     stop "Error: Failed to get phisinit ID"
     934    write(*,*) "Error: Failed to get phisinit ID"
     935    stop
    883936  endif
    884937  ! Get physinit
    885938  ierr=NF_GET_VAR_REAL(infid,tmpvarid,in_2d_data)
    886939  if (ierr.ne.NF_NOERR) then
    887     stop "Error: Failed reading input phisinit"
     940    write(*,*) "Error: Failed reading input phisinit"
     941    stop
    888942  endif
    889943 
     
    903957  ierr=NF_PUT_VAR_REAL(outfid,phisinit_varid,out_2d_data)
    904958  if (ierr.ne.NF_NOERR) then
    905     stop "Error: Could not write phisinit data to output file"
     959    write(*,*) "Error: Could not write phisinit data to output file"
     960    stop
    906961  endif
    907962endif ! of if (have_geopot)
     
    10731128
    10741129       REAL airen ((imnmx2+1)*(jmnmx2+1)) ! aire dans la nouvelle grille
    1075        REAL airentotn   ! aire totale pole nord dans la nouvelle grille
    1076        REAL airentots   ! aire totale pole sud dans la nouvelle grille
     1130       REAL airentotn   ! aire totale pole nord dans la nouvelle grille
     1131       REAL airentots   ! aire totale pole sud dans la nouvelle grille
    10771132!    Info sur les ktotal intersection entre les cases new/old grille
    10781133
Note: See TracChangeset for help on using the changeset viewer.