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

    r2546 r2567  
    2828include "netcdf.inc" ! NetCDF definitions
    2929
    30 character (len=80), dimension(1000) :: file
     30character (len=100), dimension(1000) :: file
    3131! file(): input file(s) names(s)
    3232character (len=30), dimension(16) :: notconcat
    3333! notconcat(): names of the (16) variables that won't be concatenated
    34 character (len=50), dimension(:), allocatable :: var
     34character (len=100), dimension(:), allocatable :: var
    3535! var(): name(s) of variable(s) that will be concatenated
    3636character (len=100) :: tmpvar,tmpfile,long_name,units
     
    153153if(nbfile==0) then
    154154   write(*,*) "no file... game over"
    155    stop ""
     155   stop
    156156endif
    157157
     
    183183if (ierr.NE.NF_NOERR) then
    184184   write(*,*) 'ERROR: Pb opening file '//file(1)
    185    stop ""
     185   stop
    186186endif
    187187
     
    250250write(*,*) "(an empty line , i.e: just <Enter>, implies end of list)"
    251251nbvar=0
    252 read(*,'(a50)') tmpvar
     252read(*,'(a100)') tmpvar
    253253do while ((tmpvar/=' ').AND.(trim(tmpvar)/='all'))
    254254   nbvar=nbvar+1
    255255   var(nbvar)=tmpvar
    256    read(*,'(a50)') tmpvar
     256   read(*,'(a100)') tmpvar
    257257enddo
    258258
     
    287287else if(nbvar==0) then
    288288   write(*,*) "no variable... game over"
    289    stop ""
     289   stop
    290290endif ! of if (tmpvar=="all")
    291291
     
    316316         write(*,*) 'ERROR: Pb opening file '//file(i)
    317317         write(*,*) NF_STRERROR(ierr)
    318          stop ""
     318         stop
    319319      endif
    320320   endif
     
    338338   if (ierr.NE.NF_NOERR) then
    339339      write(*,*) 'ERROR: Field <latitude> or <lat> is missing in file '//file(i)
    340       stop ""
     340      stop
    341341   endif
    342342   ierr=NF_INQ_DIMLEN(nid,latdim,latlen)
     
    347347       ierr=NF_INQ_VARID(nid,"longitude",lonvar)
    348348       if (ierr.NE.NF_NOERR) then
    349           write(*,*) 'ERROR: Field <longitude> is missing in file '//file(i)
    350           stop ""
     349          write(*,*) 'ERROR: Field <longitude> is missing in file '//file(i)
     350          stop
    351351       endif
    352352       ierr=NF_INQ_DIMLEN(nid,londim,lonlen)
     
    357357       if (ierr.NE.NF_NOERR) then
    358358          write(*,*) 'ERROR: Field <lon> is missing in file '//file(i)
    359           stop ""
     359          stop
    360360       endif
    361361       ierr=NF_INQ_DIMLEN(nid,londim,lonlen)
     
    367367   if (ierr.NE.NF_NOERR) then
    368368      write(*,*) 'ERROR: Field <altitude> is missing in file '//file(i)
    369       stop ""
     369      stop
    370370   endif
    371371   ierr=NF_INQ_DIMLEN(nid,altdim,altlen)
     
    389389!==============================================================================
    390390   if (XIOS.EQ.0) then
    391         ierr=NF_INQ_DIMID(nid,"index",ctldim)
    392         if (ierr.NE.NF_NOERR) then
    393           write(*,*) 'Dimension <index> is missing in file '//file(i)
    394           write(*,*) "The program continues..."
    395           ctllen=0
    396           !stop ""
     391        ierr=NF_INQ_DIMID(nid,"index",ctldim)
     392        if (ierr.NE.NF_NOERR) then
     393          write(*,*) 'Dimension <index> is missing in file '//file(i)
     394          write(*,*) "The program continues..."
     395          ctllen=0
     396          !stop
    397397       else
    398           ierr=NF_INQ_VARID(nid,"controle",ctlvar)
    399           if (ierr.NE.NF_NOERR) then
    400             write(*,*) 'Field <controle> is missing in file '//file(i)
    401             write(*,*) "The program continues..."
    402             ctllen=0
    403             !stop ""
    404           else
     398          ierr=NF_INQ_VARID(nid,"controle",ctlvar)
     399          if (ierr.NE.NF_NOERR) then
     400            write(*,*) 'Field <controle> is missing in file '//file(i)
     401            write(*,*) "The program continues..."
     402            ctllen=0
     403            !stop
     404          else
    405405            ierr=NF_INQ_DIMLEN(nid,ctldim,ctllen)
    406           endif
     406          endif
    407407       endif
    408408   else
     
    412412       write(*,*) "The program continues..."
    413413       ctllen=0
    414        !stop ""
     414       !stop
    415415     else
    416416       ierr=NF_INQ_VARID(nid,"controle",ctlvar)
    417417       if (ierr.NE.NF_NOERR) then
    418          write(*,*) 'Field <controle> is missing in file '//file(i)
    419         write(*,*) "The program continues..."
    420          ctllen=0
    421          !stop ""
     418         write(*,*) 'Field <controle> is missing in file '//file(i)
     419          write(*,*) "The program continues..."
     420         ctllen=0
     421          !stop
    422422        else
    423          ierr=NF_INQ_DIMLEN(nid,ctldim,ctllen)
     423         ierr=NF_INQ_DIMLEN(nid,ctldim,ctllen)
    424424       endif
    425425     endif
     
    439439   if (ierr.NE.NF_NOERR) then
    440440      write(*,*) 'ERROR: Dimension <Time> is missing in file '//file(i)
    441       stop ""
     441      stop
    442442   endif
    443443   ierr=NF_INQ_VARID(nid,"Time",timevar)
    444444   if (ierr.NE.NF_NOERR) then
    445445      write(*,*) 'ERROR: Field <Time> is missing in file '//file(i)
    446       stop ""
     446      stop
    447447   endif
    448448   ierr=NF_INQ_DIMLEN(nid,timedim,timelen)
     
    452452   if (ierr.NE.NF_NOERR) then
    453453      write(*,*) 'ERROR: Dimension <time_counter> is missing in file '//file(i)
    454       stop ""
     454      stop
    455455   endif
    456456   ierr=NF_INQ_VARID(nid,"time_counter",timevar)
    457457   if (ierr.NE.NF_NOERR) then
    458458      write(*,*) 'ERROR: Field <time_counter> is missing in file '//file(i)
    459       stop ""
     459      stop
    460460   endif
    461461   ierr=NF_INQ_DIMLEN(nid,timedim,timelen)
     
    542542      if (memolatlen/=latlen) then
    543543           write(*,*) "ERROR: Not the same latitude axis"
    544            stop ""
     544           stop
    545545       else if (memolonlen/=lonlen) then
    546546           write(*,*) "ERROR: Not the same longitude axis"
    547            stop ""
     547           stop
    548548       else if (memoaltlen/=altlen) then
    549549           write(*,*) "ERROR: Not the same altitude axis"
    550            stop ""
     550           stop
    551551       else if (memoctllen/=ctllen) then
    552552           write(*,*) "ERROR: Not the same controle axis"
    553            stop ""
     553           stop
    554554       endif
    555555   endif ! of if (i==1)
     
    582582       if (rep.eq.1) write(*,*) "Sol", int(output_time) 
    583583
    584        ierr= NF_PUT_VARA_REAL(nout,timevarout,k,1,output_time)
     584       ierr= NF_PUT_VARA_REAL(nout,timevarout,(/k/),(/1/),output_time)
    585585   end do
    586586!  use the last output_time value to update memotime   
     
    602602      if (ierr.NE.NF_NOERR) then
    603603         write(*,*) 'ERROR: Field <',var(j),'> not found in file '//file(i)
    604          stop ""
     604         stop
    605605      endif
    606606      ierr=nf_inq_varndims(nid,varid,ndim)
     
    630630         corner(4)=1
    631631
    632         ! length (along dimensions) of block of data to be written
     632        ! length (along dimensions) of block of data to be written
    633633         edges(1)=timelen
    634634         edges(2)=1
     
    648648         corner(4)=1
    649649
    650         ! length (along dimensions) of block of data to be written
     650        ! length (along dimensions) of block of data to be written
    651651         edges(1)=lonlen
    652652         edges(2)=latlen
     
    667667         corner(4)=reptime+1
    668668
    669         ! length (along dimensions) of block of data to be written
     669        ! length (along dimensions) of block of data to be written
    670670         edges(1)=lonlen
    671671         edges(2)=latlen
     
    699699      if (ierr.ne.NF_NOERR) then
    700700         write(*,*) 'PUT_VAR ERROR: ',NF_STRERROR(ierr)
    701          stop ""
     701         stop
    702702      endif
    703703
     
    812812if (ierr.NE.NF_NOERR) then
    813813   WRITE(*,*)'ERROR: Impossible to create the file.'
    814    stop ""
     814   stop
    815815endif
    816816
     
    963963  hybrid=.true.
    964964  if (ierr.ne.NF_NOERR) then
    965     stop "init2 Error: Failed reading aps"
     965    write(*,*) "init2 Error: Failed reading aps"
     966    stop
    966967  endif
    967968
     
    975976  ierr=NF_INQ_VARID(infid,"bps",tmpvarid)
    976977  if (ierr.ne.NF_NOERR) then
    977     stop "init2 Error: Failed to get bps ID."
     978    write(*,*) "init2 Error: Failed to get bps ID."
     979    stop
    978980  endif
    979981  ierr=NF_GET_VAR_REAL(infid,tmpvarid,bps)
    980982  if (ierr.ne.NF_NOERR) then
    981     stop "init2 Error: Failed reading bps"
     983    write(*,*) "init2 Error: Failed reading bps"
     984    stop
    982985  endif
    983986endif
     
    9971000  apbp=.true.
    9981001  if (ierr.ne.NF_NOERR) then
    999     stop "Error: Failed reading ap"
     1002    write(*,*) "Error: Failed reading ap"
     1003    stop
    10001004  endif
    10011005endif
     
    10151019  apbp=.true.
    10161020  if (ierr.ne.NF_NOERR) then
    1017     stop "Error: Failed reading bp"
     1021    write(*,*) "Error: Failed reading bp"
     1022    stop
    10181023  endif
    10191024endif
     
    10341039    sig=.true.
    10351040    if (ierr.ne.NF_NOERR) then
    1036       stop "init2 Error: Failed reading sigma"
     1041      write(*,*) "init2 Error: Failed reading sigma"
     1042      stop
    10371043    endif
    10381044  endif
     
    10521058  ierr=NF_GET_VAR_REAL(infid,tmpvarid,aire)
    10531059  if (ierr.ne.NF_NOERR) then
    1054     stop "init2 Error: Failed reading aire"
     1060    write(*,*) "init2 Error: Failed reading aire"
     1061    stop
    10551062  endif
    10561063  area = .true.
     
    10701077  ierr=NF_GET_VAR_REAL(infid,tmpvarid,phisinit)
    10711078  if (ierr.ne.NF_NOERR) then
    1072     stop "init2 Error: Failed reading phisinit"
     1079    write(*,*) "init2 Error: Failed reading phisinit"
     1080    stop
    10731081  endif
    10741082  phis = .true.
     
    10871095             (/layerdimout/),apsid,ierr)
    10881096  if (ierr.ne.NF_NOERR) then
    1089     stop "init2 Error: Failed to def_var aps"
     1097    write(*,*) "init2 Error: Failed to def_var aps"
     1098    stop
    10901099  endif
    10911100
     
    10931102  ierr=NF_PUT_VAR_REAL(outfid,apsid,aps)
    10941103  if (ierr.ne.NF_NOERR) then
    1095     stop "init2 Error: Failed to write aps"
     1104    write(*,*) "init2 Error: Failed to write aps"
     1105    stop
    10961106  endif
    10971107
     
    11001110             (/layerdimout/),bpsid,ierr)
    11011111  if (ierr.ne.NF_NOERR) then
    1102     stop "init2 Error: Failed to def_var bps"
     1112    write(*,*) "init2 Error: Failed to def_var bps"
     1113    stop
    11031114  endif
    11041115
     
    11061117  ierr=NF_PUT_VAR_REAL(outfid,bpsid,bps)
    11071118  if (ierr.ne.NF_NOERR) then
    1108     stop "init2 Error: Failed to write bps"
     1119    write(*,*) "init2 Error: Failed to write bps"
     1120    stop
    11091121  endif
    11101122
     
    11141126             (/interlayerdimout/),apid,ierr)
    11151127    if (ierr.ne.NF_NOERR) then
    1116       stop "Error: Failed to def_var ap"
     1128      write(*,*) "Error: Failed to def_var ap"
     1129      stop
    11171130    endif
    11181131
     
    11201133    ierr=NF_PUT_VAR_REAL(outfid,apid,ap)
    11211134    if (ierr.ne.NF_NOERR) then
    1122       stop "Error: Failed to write ap"
     1135      write(*,*) "Error: Failed to write ap"
     1136      stop
    11231137    endif
    11241138
     
    11271141             (/interlayerdimout/),bpid,ierr)
    11281142    if (ierr.ne.NF_NOERR) then
    1129       stop "Error: Failed to def_var bp"
     1143      write(*,*) "Error: Failed to def_var bp"
     1144      stop
    11301145    endif
    11311146
     
    11331148    ierr=NF_PUT_VAR_REAL(outfid,bpid,bp)
    11341149    if (ierr.ne.NF_NOERR) then
    1135       stop "Error: Failed to write bp"
     1150      write(*,*) "Error: Failed to write bp"
     1151      stop
    11361152    endif
    11371153  endif ! of if (apbp)
     
    11421158             (/layerdimout/),sigmaid,ierr)
    11431159  if (ierr.ne.NF_NOERR) then
    1144     stop "init2 Error: Failed to def_var sigma"
     1160    write(*,*) "init2 Error: Failed to def_var sigma"
     1161    stop
    11451162  endif
    11461163! write sigma
    11471164  ierr=NF_PUT_VAR_REAL(outfid,sigmaid,sigma)
    11481165  if (ierr.ne.NF_NOERR) then
    1149     stop "init2 Error: Failed to write sigma"
     1166    write(*,*) "init2 Error: Failed to write sigma"
     1167    stop
    11501168  endif
    11511169endif ! of if (hybrid)
     
    11601178           (/londimout,latdimout/),tmpvarid,ierr)
    11611179  if (ierr.ne.NF_NOERR) then
    1162      stop "init2 Error: Failed to def_var aire"
     1180     write(*,*) "init2 Error: Failed to def_var aire"
     1181     stop
    11631182  endif
    11641183 
     
    11661185  ierr=NF_PUT_VAR_REAL(outfid,tmpvarid,aire)
    11671186  if (ierr.ne.NF_NOERR) then
    1168     stop "init2 Error: Failed to write aire"
     1187    write(*,*) "init2 Error: Failed to write aire"
     1188    stop
    11691189  endif
    11701190endif ! of if (area)
     
    11761196            (/londimout,latdimout/),phisinitid,ierr)
    11771197   if (ierr.ne.NF_NOERR) then
    1178      stop "init2 Error: Failed to def_var phisinit"
     1198     write(*,*) "init2 Error: Failed to def_var phisinit"
     1199     stop
    11791200   endif
    11801201
     
    11821203  ierr=NF_PUT_VAR_REAL(outfid,phisinitid,phisinit)
    11831204  if (ierr.ne.NF_NOERR) then
    1184     stop "init2 Error: Failed to write phisinit"
     1205    write(*,*) "init2 Error: Failed to write phisinit"
     1206    stop
    11851207  endif
    11861208
     
    12961318   write(*,*) 'ERROR in change_time_axis: Field <Time> not found'
    12971319   print*, NF_STRERROR(ierr)
    1298    stop ""
     1320   stop
    12991321endif
    13001322
     
    14941516   !write(*,*) 'NF_NOERR', NF_NOERR
    14951517   !CALL abort
    1496    stop ""
     1518   stop
    14971519endif
    14981520
     
    15051527!    WRITE(*,*) 'NF_NOERR', NF_NOERR
    15061528!    CALL abort
    1507    stop ""
     1529   stop
    15081530endif
    15091531
Note: See TracChangeset for help on using the changeset viewer.