Skip to content

Commit a74fb54

Browse files
Merge pull request #63 from TimMarchok-NOAA/fix_alloc_array_and_unit_nums
Fix allocatable arrays and allow EMC unit numbers
2 parents 5d0a709 + b87c0a2 commit a74fb54

File tree

3 files changed

+105
-45
lines changed

3 files changed

+105
-45
lines changed

code/src/support/tave/tave.f

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,16 +1070,29 @@ subroutine open_grib_files (lugb,lugi,lout,gribver,iret)
10701070

10711071
implicit none
10721072

1073-
character fnameg*7,fnamei*7,fnameo*7
1073+
character fnameg*255,fnamei*255,fnameo*255
1074+
character enameb*16,enamei*16,enameo*16
1075+
character lugb_c*16,lugi_c*16,lout_c*16
10741076
integer iret,gribver,lugb,lugi,lout,igoret,iioret,iooret
10751077

10761078
iret=0
1077-
fnameg(1:5) = "fort."
1078-
fnamei(1:5) = "fort."
1079-
fnameo(1:5) = "fort."
1080-
write(fnameg(6:7),'(I2)') lugb
1081-
write(fnamei(6:7),'(I2)') lugi
1082-
write(fnameo(6:7),'(I2)') lout
1079+
write(lugb_c,'(I2.2)')lugb
1080+
write(lugi_c,'(I2.2)')lugi
1081+
write(lout_c,'(I2.2)')lout
1082+
enameb='FORT'//lugb_c
1083+
enamei='FORT'//lugi_c
1084+
enameo='FORT'//lout_c
1085+
call get_environment_variable(trim(enameb), fnameg, status=igoret)
1086+
call get_environment_variable(trim(enamei), fnamei, status=iioret)
1087+
call get_environment_variable(trim(enameo), fnameo, status=iooret)
1088+
if (igoret /= 0 .or. iioret /= 0 .or. iooret /= 0) then
1089+
fnameg(1:5) = "fort."
1090+
fnamei(1:5) = "fort."
1091+
fnameo(1:5) = "fort."
1092+
write(fnameg(6:7),'(I2)') lugb
1093+
write(fnamei(6:7),'(I2)') lugi
1094+
write(fnameo(6:7),'(I2)') lout
1095+
endif
10831096
call baopenr (lugb,fnameg,igoret)
10841097
call baopenr (lugi,fnamei,iioret)
10851098
call baopenw (lout,fnameo,iooret)

code/src/support/vint/vint.f

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -956,18 +956,18 @@ subroutine output_data (lout,kf,kpds,kgds,holdgfld,xoutdat
956956
real coordlist
957957
real xoutdat(kf,nlevsout),xoutlevs_p(nlevsout)
958958
c
959-
iodret=0
960-
call baopenw (lout,"fort.51",igoret)
961-
print *,'baopenw: igoret= ',igoret
962-
963-
if (igoret /= 0) then
964-
print *,' '
965-
print *,'!!! ERROR in vint in sub output_data opening'
966-
print *,'!!! **OUTPUT** grib file. baopenw return codes:'
967-
print *,'!!! grib file 1 return code = igoret = ',igoret
968-
STOP 95
969-
return
970-
endif
959+
c iodret=0
960+
c call baopenw (lout,"fort.51",igoret)
961+
c print *,'baopenw: igoret= ',igoret
962+
963+
c if (igoret /= 0) then
964+
c print *,' '
965+
c print *,'!!! ERROR in vint in sub output_data opening'
966+
c print *,'!!! **OUTPUT** grib file. baopenw return codes:'
967+
c print *,'!!! grib file 1 return code = igoret = ',igoret
968+
c STOP 95
969+
c return
970+
c endif
971971

972972
levloop: do lev = 1,nlevsout
973973

@@ -1209,16 +1209,29 @@ subroutine open_grib_files (lugb,lugi,lout,gribver,iret)
12091209

12101210
implicit none
12111211

1212-
character fnameg*7,fnamei*7,fnameo*7
1212+
character(2) lugb_c,lugi_c,lout_c
1213+
character(255) fnameg,fnamei,fnameo
1214+
character(6) enameb,enamei,enameo
12131215
integer iret,gribver,lugb,lugi,lout,igoret,iioret,iooret
12141216

12151217
iret=0
1216-
fnameg(1:5) = "fort."
1217-
fnamei(1:5) = "fort."
1218-
fnameo(1:5) = "fort."
1219-
write(fnameg(6:7),'(I2)') lugb
1220-
write(fnamei(6:7),'(I2)') lugi
1221-
write(fnameo(6:7),'(I2)') lout
1218+
write(lugb_c,'(i2)')lugb
1219+
write(lugi_c,'(i2)')lugi
1220+
write(lout_c,'(i2)')lout
1221+
enameb='FORT'//adjustl(lugb_c)
1222+
enamei='FORT'//adjustl(lugi_c)
1223+
enameo='FORT'//adjustl(lout_c)
1224+
call get_environment_variable(enameb,fnameg, status=igoret)
1225+
call get_environment_variable(enamei, fnamei, status=iioret)
1226+
call get_environment_variable(enameo, fnameo, status=iooret)
1227+
if (igoret /= 0 .or. iioret /= 0 .or. iooret /= 0) then
1228+
fnameg(1:5) = "fort."
1229+
fnamei(1:5) = "fort."
1230+
fnameo(1:5) = "fort."
1231+
write(fnameg(6:7),'(I2)') lugb
1232+
write(fnamei(6:7),'(I2)') lugi
1233+
write(fnameo(6:7),'(I2)') lout
1234+
endif
12221235
call baopenr (lugb,fnameg,igoret)
12231236
call baopenr (lugi,fnamei,iioret)
12241237
call baopenw (lout,fnameo,iooret)

code/src/tracker/gettrk_subroutines.f

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -883,12 +883,18 @@ subroutine tracker (inp,maxstorm,numtcv,ifhmax,trkrinfo,ncfile
883883
v = -9999.0
884884
slp = -9999.0
885885
tmean = -9999.0
886-
sst = -9999.0
887-
q850 = -9999.0
888-
rh = -9999.0
889-
spfh = -9999.0
890-
temperature = -9999.0
891-
omega500 = -9999.0
886+
887+
if (sstflag == 'y' .or. sstflag == 'Y') then
888+
sst = -9999.0
889+
endif
890+
891+
if (genflag == 'y' .or. genflag == 'Y') then
892+
q850 = -9999.0
893+
rh = -9999.0
894+
spfh = -9999.0
895+
temperature = -9999.0
896+
omega500 = -9999.0
897+
endif
892898

893899
readflag = .FALSE.
894900
readgenflag = .FALSE.
@@ -4337,7 +4343,9 @@ subroutine open_grib_files (inp,lugb,lugi,gfilename,ifilename
43374343
logical(1) output_file_open
43384344
logical(1) file_open
43394345
logical(4) file_open4,file_open5
4340-
character fnameg*7,fnamei*7,fnameo*7
4346+
character fnameg*255,fnamei*255,fnameo*255
4347+
character enameb*16,enamei*16,enameo*16
4348+
character lugb_c*16,lugi_c*16,lout_c*16
43414349
character fname_mask_g*7,fname_mask_i*7
43424350
character opening_mask*1
43434351
character(*) gfilename,ifilename
@@ -4351,20 +4359,41 @@ subroutine open_grib_files (inp,lugb,lugi,gfilename,ifilename
43514359
iooret = 0
43524360

43534361
if (inp%file_seq == 'onebig') then
4354-
fnameg(1:5) = "fort."
4355-
fnamei(1:5) = "fort."
4356-
write(fnameg(6:7),'(I2)') lugb
4357-
write(fnamei(6:7),'(I2)') lugi
4362+
4363+
write(lugb_c,'(I2.2)')lugb
4364+
write(lugi_c,'(I2.2)')lugi
4365+
enameb='FORT'//lugb_c
4366+
enamei='FORT'//lugi_c
4367+
call get_environment_variable(trim(enameb), fnameg
4368+
& , status=igoret)
4369+
call get_environment_variable(trim(enamei), fnamei
4370+
& , status=iioret)
4371+
4372+
if (igoret /= 0 .or. iioret /= 0) then
4373+
fnameg(1:5) = "fort."
4374+
fnamei(1:5) = "fort."
4375+
write(fnameg(6:7),'(I2)') lugb
4376+
write(fnamei(6:7),'(I2)') lugi
4377+
endif
4378+
43584379
call baopenr (lugb,fnameg,igoret)
43594380
call baopenr (lugi,fnamei,iioret)
4381+
43604382
if (opening_mask /= 'y') then
43614383
! If this is a regular call to open_grib_files (i.e., not
43624384
! for opening the land-sea mask file), then open the
43634385
! output grib file unit.
4364-
fnameo(1:5) = "fort."
4365-
write(fnameo(6:7),'(I2)') lout
4366-
call baopenw (lout,fnameo,iooret)
4386+
write(lout_c,'(I2.2)')lout
4387+
enameo='FORT'//lout_c
4388+
call get_environment_variable(trim(enameo), fnameo
4389+
& , status=iooret)
4390+
if (iooret /= 0) then
4391+
fnameo(1:5) = "fort."
4392+
write(fnameo(6:7),'(I2)') lout
4393+
call baopenw (lout,fnameo,iooret)
4394+
endif
43674395
endif
4396+
43684397
else
43694398

43704399
if (opening_mask == 'y') then
@@ -4375,7 +4404,9 @@ subroutine open_grib_files (inp,lugb,lugi,gfilename,ifilename
43754404
print *,'!!! inp%file_seq flag indicates that this is not'
43764405
print *,'!!! a onebig file, and as of yet, the functionality'
43774406
print *,'!!! for an additional land-sea mask file can only'
4378-
print *,'!!! be used for onebig file applications.'
4407+
print *,'!!! be used for onebig file applications. As an'
4408+
print *,'!!! alternative, you can include a land-sea mask'
4409+
print *,'!!! record within each individual file.'
43794410
stop 95
43804411
endif
43814412

@@ -4413,7 +4444,7 @@ subroutine open_grib_files (inp,lugb,lugi,gfilename,ifilename
44134444
inquire (unit=lugb, opened=file_open)
44144445
if (file_open) then
44154446
print *,'TEST open_grib_files, unit lugb= ',lugb
4416-
& ,' is OPEN'
4447+
& ,' is OPEN'
44174448
else
44184449
print *,'TEST open_grib_files, unit lugb= ',lugb
44194450
& ,' is CLOSED'
@@ -4476,6 +4507,7 @@ subroutine open_grib_files (inp,lugb,lugi,gfilename,ifilename
44764507

44774508
iret = 113
44784509
return
4510+
44794511
endif
44804512

44814513
return
@@ -12979,8 +13011,8 @@ subroutine output_atcf_gen (outlon,outlat,inp,ist
1297913011
& ,'_',a3,', ',i10.10,', 03, ',a4,', ',i3.3,', ',i3,a1
1298013012
& ,', ',i4,a1,', ',i3,', ',i4,', ',a12,4(', ',i4.4)
1298113013
& ,', ',3(i4,', '),3(i6,', '),a1,2(', ',i4),4(', ',i6)
12982-
& ,', SHR82, ',i4,', ',i3,', ',i5,3(', ',i4),2(', ',i9)
12983-
& ,3(', ',i4))
13014+
& ,', SHR82, ',i4,', ',i3,', ',i5,3(', ',i4),', ',i9
13015+
& ,', ',i11,3(', ',i4))
1298413016

1298513017
c bug fix for IBM: flush the output stream so it actually writes
1298613018
flush(66)
@@ -20871,6 +20903,8 @@ subroutine find_maxmin (imax,jmax,dx,dy,cparm,fxy,maxmin,ist
2087120903
print *,' The immediately following lines for ilonfix, jlatfix,'
2087220904
print *,' ibeg, jbeg, iend and jend likely contain junk values'
2087320905
print *,' since we have not yet called get_ij_bounds....'
20906+
ilonfix = -9999
20907+
jlatfix = -9999
2087420908
print *,' ilonfix= ',ilonfix,' jlatfix= ',jlatfix
2087520909
print *,' ibeg= ',ibeg
2087620910
print *,' jbeg= ',jbeg
@@ -28977,7 +29011,7 @@ subroutine getgridinfo_grib (imax,jmax,ifh,dx,dy,lugb,lugi
2897729011
print *,' GRID MIN & MAX LON '
2897829012
print *,' (MODIFIED FOR GM WRAPPING):'
2897929013
print *,' glonmin (same as original)= ',glonmin
28980-
print *,' glonmax (modified)= ',glonmax
29014+
print *,' glonmax (modified)= ',glonmax+360.
2898129015
print *,' '
2898229016
endif
2898329017
glonmax = glonmax + 360.

0 commit comments

Comments
 (0)