8 #define CHECK_ERR(I) CHECK_ERROR(I, __LINE__)
182 USE w3adatmd,
ONLY:
dw,
ua,
ud,
as,
cx,
cy,
hs,
wlm,
t0m1,
thm, &
225 INTEGER :: ndsi, ndsm, ndsog, &
226 ndstrc, ntrace, ierr, i, i1f, i2f, &
228 ifi, ifj, nctype, ix1, ixn, iy1, iyn, &
230 nbipart, cntipart, ncvartypei, ipart, &
232 INTEGER :: tout(2), tdum(2), tref(2), tepoch(2), &
233 stopdate(8), refdate(8)
235 INTEGER,
ALLOCATABLE :: tabipart(:), ncids(:,:,:)
238 INTEGER,
SAVE :: ient = 0
243 CHARACTER*30 :: strstopdate, fileprefix, stringipart
244 CHARACTER*1024 :: fldout
245 CHARACTER :: comstr*1, idtime*23, iddday*11, ttype*1
248 vector, together, flgnml, flgfc
249 LOGICAL :: mapstaout = .true.
250 LOGICAL :: smcgrd = .false.
252 LOGICAL :: rtdl = .false.
255 INTEGER :: tvartype = nf90_double
256 CHARACTER(LEN=32) :: epoch_iso
257 CHARACTER(LEN=64) :: epoch
258 CHARACTER :: timeunit*1
269 CALL w3setw ( 1, 6, 6 )
271 CALL w3seta ( 1, 6, 6 )
273 CALL w3seto ( 1, 6, 6 )
281 CALL itrace ( ndstrc, ntrace )
284 CALL strace (ient,
'W3OUNF')
296 CALL w3iogr (
'READ', ndsm )
301 IF (
polat < 90. ) rtdl = .true.
308 CALL w3iogo (
'READ', ndsog, iotest )
320 WRITE (
ndso, *)
" Conversion for SMCTYPE:",
gtype
329 INQUIRE(
file=trim(
fnmpre)//
"ww3_ounf.nml", exist=flgnml)
333 nml_file, nml_smc, ierr)
336 READ(nml_field%TIMESTRIDE, *) dtreq
337 READ(nml_field%TIMECOUNT, *) nout
338 READ(nml_field%TIMESTART, *) tout(1), tout(2)
339 READ(nml_field%TIMEREF, *) tref(1), tref(2)
340 READ(nml_field%TIMEEPOCH, *) tepoch(1), tepoch(2)
343 fldout = nml_field%LIST
346 IF (ierr.NE.0)
GOTO 800
349 nctype = nml_file%NETCDF
351 stringipart = nml_field%PARTITION
352 together = nml_field%SAMEFILE
353 vector = nml_field%VECTOR
354 fileprefix = nml_file%PREFIX
355 flgfc = nml_field%FCVARS
356 s3 = nml_field%TIMESPLIT
357 ttype = nml_field%TIMEVAR
358 timeunit = nml_field%TIMEUNIT
359 noval = nml_field%NOVAL
360 mapstaout = nml_field%MAPSTA
381 IF (.NOT. flgnml)
THEN
382 OPEN (ndsi,
file=trim(
fnmpre)//
'ww3_ounf.inp',status=
'OLD',err=800,iostat=ierr)
385 READ (ndsi,
'(A)',
END=801,ERR=802,IOSTAT=IERR) comstr
386 IF (comstr.EQ.
' ') comstr =
'$'
387 WRITE (ndso,901) comstr
388 CALL nextln ( comstr , ndsi , ndse )
391 READ (ndsi,*,
END=801,ERR=802) TOUT, DTREQ, nout
404 CALL w3readflgrd ( ndsi, ndso, screen, ndse, comstr, flg1d, &
406 IF (ierr.NE.0)
GOTO 800
409 CALL nextln ( comstr , ndsi , ndse )
410 READ (ndsi,*,
END=801,ERR=802) NCTYPE, ncvartype
411 CALL nextln ( comstr , ndsi , ndse )
412 READ (ndsi,
'(A)',
END=801,ERR=802) stringipart
413 CALL nextln ( comstr , ndsi , ndse )
414 READ (ndsi,*,
END=801,ERR=802) together
423 CALL nextln ( comstr , ndsi , ndse )
425 READ (ndsi,*,
END=801,ERR=802) fileprefix
426 CALL nextln ( comstr , ndsi , ndse )
427 READ (ndsi,*,
END=801,ERR=802) s3
428 CALL nextln ( comstr , ndsi , ndse )
433 READ (ndsi,*,
END=801,ERR=802) smcotype
434 IF(smcotype .EQ. 1)
THEN
435 CALL nextln ( comstr , ndsi , ndse )
436 READ (ndsi,*,
END=801,ERR=802) SXO, SYO, EXO, eyo
437 ELSE IF(smcotype .EQ. 2)
THEN
438 CALL nextln ( comstr , ndsi , ndse )
439 READ (ndsi,*,
END=801,ERR=802) SXO, SYO, EXO, EYO, celfac
444 READ (ndsi,*,
END=801,ERR=802) IX1, IXN, IY1, iyn
447 CLOSE(ndsi,err=800,iostat=ierr)
450 CALL str_to_upper(ttype)
451 CALL str_to_upper(timeunit)
453 IF(timeunit /=
'S' .AND. timeunit /=
'D')
THEN
454 WRITE(ndse, 1013) timeunit
460 tvartype = nf90_double
462 tvartype = nf90_int64
464 WRITE(ndse, 1014) ttype
468 IF(ttype .EQ.
'I' .AND. timeunit .EQ.
'D')
THEN
474 IF(tvartype .EQ. nf90_int64 .AND. nctype .LT. 4)
THEN
480 ncvartypei = ncvartype
483 CALL t2d(tref, refdate, ierr)
487 dtreq = max( 0. , dtreq )
488 IF ( dtreq.EQ.0. ) nout = 1
489 nout = max( 1 , nout )
490 CALL stme21 ( tout , idtime )
491 WRITE (ndso,940) idtime
493 CALL tick21 ( tdum , dtreq )
494 CALL stme21 ( tdum , idtime )
495 IF ( dtreq .GE. 86400. )
THEN
496 WRITE (iddday,
'(I10,1X)') int(dtreq/86400.)
500 idtime(1:11) = iddday
502 WRITE (ndso,941) idtime, nout
505 CALL stme21 ( tref , idtime )
506 WRITE(ndso,942) idtime
512 IF ( flg2d(ifi,ifj) )
THEN
513 IF ( flogrd(ifi,ifj) )
THEN
514 WRITE (ndso,946) idout(ifi,ifj),
' '
516 WRITE (ndso,946) idout(ifi,ifj),
'*** NOT AVAILABLE ***'
517 flg2d(ifi,ifj) = .false.
525 ALLOCATE(tabipart(noswll + 1))
526 ALLOCATE(ncids(nogrp,ngrpp,noswll + 1))
529 IF(stringipart(i:i) .EQ.
' ') cycle
530 READ(stringipart(i:i),
'(I1)') ipart
531 IF(ipart .GT. noswll)
THEN
532 WRITE(ndso, 1500) ipart, noswll
535 nbipart = nbipart + 1
536 IF(nbipart .GT. noswll + 1)
THEN
539 tabipart(nbipart) = ipart
542 IF ( nctype.LT.3 .OR. nctype.GT.4 )
THEN
543 WRITE (ndse,1010) nctype
550 IF(smcotype .EQ. 1)
THEN
551 ALLOCATE(smcmask(nsea))
552 ALLOCATE(smcidx(nsea))
555 smcnout = count(smcmask)
558 WRITE(ndso, 4120) smcnout
559 ELSE IF(smcotype .EQ. 2)
THEN
561 ALLOCATE(xidx(nsea), yidx(nsea), xspan(nsea), &
562 yspan(nsea), wts(nsea), smcidx(nsea))
564 WRITE(ndso, 4110) nxo, nyo, sxo, syo, dxo, dyo
567 ALLOCATE(cov(nxo,nyo), mapsmc(nxo,nyo))
568 ELSE IF(smcotype .EQ. 3 .OR. smcotype .EQ. 4)
THEN
587 IF(smcotype .EQ. 3 .OR. smcotype .EQ. 4) rtdl = .false.
592 ixn = min( ixn , nx )
594 iyn = min( iyn , ny )
595 WRITE (ndso,3940) ix1, ixn, iy1, iyn
599 CALL init_meta(vector)
610 dtest = dsec21( time , tout )
611 IF ( dtest .GT. 0. )
THEN
612 CALL w3iogo (
'READ', ndsog, iotest )
613 IF ( iotest .EQ. -1 )
THEN
619 IF ( dtest .LT. 0. )
THEN
620 CALL tick21 ( tout , dtreq )
627 CALL stme21 ( tout , idtime )
628 WRITE (ndso,971) idtime
632 CALL w3exnc ( nx, ny, ix1, ixn, iy1, iyn, nsea, fileprefix, &
633 e3df, p2msf, us3df, usspf, nctype, together, ncvartypei,&
634 flg2d, ncids, s3, strstopdate )
637 CALL t2d(tout,stopdate,ierr)
638 WRITE(strstopdate,
'(I4.4,A,4(I2.2,A),I2.2)') stopdate(1),
'-',stopdate(2), &
639 '-',stopdate(3),
' ',stopdate(5),
':',stopdate(6),
':',stopdate(7)
641 CALL tick21 ( tout , dtreq )
642 IF ( iout .GE. nout )
EXIT
649 IF (together .AND. ncids(1,1,1).NE.0)
THEN
650 iret = nf90_redef(ncids(1,1,1))
652 IF(fl_default_gbl_meta)
THEN
653 iret=nf90_put_att(ncids(1,1,1),nf90_global,
'stop_date',strstopdate)
656 iret=nf90_close(ncids(1,1,1))
662 IF ( flg2d(ifi,ifj) )
THEN
663 IF ( flogrd(ifi,ifj) )
THEN
664 IF (.NOT. together)
THEN
665 IF (ncids(ifi,ifj,1).NE.0)
THEN
666 iret = nf90_redef(ncids(ifi,ifj,1))
668 IF(fl_default_gbl_meta)
THEN
669 iret=nf90_put_att(ncids(ifi,ifj,1),nf90_global,
'stop_date',strstopdate)
672 iret=nf90_close(ncids(ifi,ifj,1))
676 IF ((ifi.EQ.4).AND.(ifj.LE.noge(ifi)))
THEN
678 IF (ncids(ifi,ifj,ipart+1).NE.0)
THEN
679 iret = nf90_redef(ncids(ifi,ifj,ipart+1))
681 IF(fl_default_gbl_meta)
THEN
682 iret=nf90_put_att(ncids(ifi,ifj,ipart+1),nf90_global,
'stop_date',strstopdate)
685 iret=nf90_close(ncids(ifi,ifj,ipart+1))
693 IF ( ((ifi.EQ.6).AND.(ifj.EQ.8)) .OR. &
694 ((ifi.EQ.6).AND.(ifj.EQ.9)) .OR. &
696 IF (ncids(ifi,ifj,1).NE.0)
THEN
697 iret = nf90_redef(ncids(ifi,ifj,1))
699 IF(fl_default_gbl_meta)
THEN
700 iret=nf90_put_att(ncids(ifi,ifj,1),nf90_global,
'stop_date',strstopdate)
703 iret=nf90_close(ncids(ifi,ifj,1))
719 WRITE (ndse,1000) ierr
727 WRITE (ndse,1002) ierr
731 WRITE (ndse,1003) nbipart, noswll
739 900
FORMAT (/15x,
' *** WAVEWATCH III Field output postp. *** '/ &
740 15x,
'==============================================='/)
741 901
FORMAT (
' Comment character is ''',a,
''''/)
743 920
FORMAT (
' Grid name : ',a/)
745 930
FORMAT (
' Fields in file : '/ &
746 ' --------------------------')
749 940
FORMAT (/
' Output time data : '/ &
750 ' --------------------------------------------------'/ &
752 941
FORMAT (
' Interval : ',a/ &
753 ' Number of requests : ',i10)
754 942
FORMAT (
' Reference time : ',a)
755 944
FORMAT (/
' End of file reached '/)
756 946
FORMAT (
' ',a,2x,a)
758 3940
FORMAT (
' X range : ',2i7/ &
762 4100
FORMAT (//
' SMC grid output :' / &
763 ' --------------------------------------------------')
764 4110
FORMAT (
' SMC to regular lat/lon grid using cell averaging' /&
765 ' Aligned output grid definition: ' / &
766 ' NX, NY : ', 2i8 / &
767 ' X0, Y0 : ', 2f8.3 / &
768 ' DX, DY : ', 2f8.5 )
769 4120
FORMAT (
' Flat seapoint dimensioned SMC output file' / &
770 ' Num seapoints : ',i9 )
772 4130
FORMAT (
' SMC regridding to regular lat/lon grid.' / &
773 ' Output grid definition: ' / &
774 ' NX, NY : ', 2i8 / &
775 ' X0, Y0 : ', 2f8.3 / &
776 ' DX, DY : ', 2f8.5 / &
777 ' Interpolate ? : ', l )
780 970
FORMAT (/
' Generating files '/ &
781 ' --------------------------------------------------')
782 971
FORMAT (
' Files for ',a)
784 999
FORMAT (/
' End of program '/ &
785 ' ========================================='/ &
786 ' WAVEWATCH III Field output '/)
790 1000
FORMAT (/
' *** WAVEWATCH III ERROR IN W3OUNF : '/ &
791 ' ERROR IN OPENING INPUT FILE'/ &
794 1001
FORMAT (/
' *** WAVEWATCH III ERROR IN W3OUNF : '/ &
795 ' PREMATURE END OF INPUT FILE'/)
797 1002
FORMAT (/
' *** WAVEWATCH III ERROR IN W3OUNF : '/ &
798 ' ERROR IN READING FROM INPUT FILE'/ &
801 1003
FORMAT (/
' *** WAVEWATCH III WERROR IN W3OUNF : '/ &
802 ' OUT OF RANGE REQUEST FOR NBIPART =',i2, / &
803 ' MAX SWELL PARTITIONS (NOSW) =',i2 /)
805 1010
FORMAT (/
' *** WAVEWATCH III ERROR IN W3OUNF : '/ &
806 ' ILLEGAL TYPE, NCTYPE =',i4/)
808 1013
FORMAT (/
' *** WAVEWATCH III ERROR IN W3OUNF : '/ &
809 ' TIMEUNITS MUST BE ONE OF "S" OR "D"' / &
812 1014
FORMAT (/
' *** WAVEWATCH III ERROR IN W3OUNF : '/ &
813 ' TIMEVAR TYPE MUST BE ONE OF "I" OR "D"' / &
816 1015
FORMAT (/
' *** WAVEWATCH III ERROR IN W3OUNF : '/ &
817 ' CANNONT HAVE TIME UNITS OF DAYS WITH'/ &
818 ' TIME VARYTPE OF INT64' /)
820 1016
FORMAT (/
' *** WAVEWATCH III ERROR IN W3OUNF : '/ &
821 ' INT64 TIME ENCODING REQUIRES NETCDF4' / &
826 1500
FORMAT (/
' *** WAVEWATCH III WARNING IN W3OUNF : '/ &
827 ' IGNORING REQUEST FOR IPART =',i2, / &
828 ' MAX SWELL PARTITIONS (NOSW) =',i2 /)
860 SUBROUTINE w3exnc ( NX, NY, IX1, IXN, IY1, IYN, NSEA, &
861 FILEPREFIX, E3DF, P2MSF, US3DF, USSPF,NCTYPE, &
862 TOGETHER, NCVARTYPEI, FLG2D, NCIDS, S3, STRSTOPDATE )
967 INTEGER,
INTENT(IN) :: NX, NY, IX1, IXN, IY1, IYN, NSEA, &
968 E3DF(3,5), P2MSF(3), US3DF(3), &
969 USSPF(2), NCTYPE, NCVARTYPEI
970 CHARACTER(30) :: FILEPREFIX
971 LOGICAL,
INTENT(IN) :: TOGETHER
972 LOGICAL,
INTENT(IN) :: FLG2D(NOGRP,NGRPP)
973 INTEGER,
INTENT(INOUT) :: NCIDS(NOGRP,NGRPP,NOSWLL + 1), S3
974 CHARACTER*30,
INTENT(IN) :: STRSTOPDATE
979 INTEGER :: IFI, IFJ, MFILL, I, J, ISEA, IX, IY, &
980 I1, J1, IPART, INDEXIPART, COORDTYPE
981 INTEGER :: S1, S2, S4, S5, NCID, OLDNCID, NDSDAT,&
982 NFIELD, N, IRET, IK, EXTRADIM, IVAR, &
984 INTEGER :: DIMID(6), VARID(300), START(4), &
985 COUNT(4), DIMLN(6),START1D(2), &
986 COUNT1D(2), DIMFIELD(3), &
987 STARTDATE(8), CURDATE(8), &
989 MAP(NX+1,NY), MP2(NX+1,NY)
993 INTEGER,
SAVE :: IENT = 0
997 INTEGER(KIND=2),
ALLOCATABLE :: MX1(:,:), MXX(:,:), MYY(:,:), &
998 MXY(:,:), MAPOUT(:,:)
1000 REAL :: CABS, UABS, MFILLR
1002 REAL,
PARAMETER :: LOG2=log(2.)
1005 REAL,
DIMENSION(:),
ALLOCATABLE :: LON, LAT, FREQ
1006 REAL,
DIMENSION(:,:),
ALLOCATABLE :: LON2D, LAT2D, ANGLD2D
1008 REAL,
DIMENSION(:,:),
ALLOCATABLE :: LON2DEQ, LAT2DEQ
1011 REAL,
ALLOCATABLE :: X1(:,:), X2(:,:), XX(:,:), XY(:,:), &
1012 XK(:,:,:), XXK(:,:,:), XYK(:,:,:), &
1013 MX1R(:,:), MXXR(:,:), MYYR(:,:), &
1016 DOUBLE PRECISION :: OUTJULDAY
1017 INTEGER(KIND=8) :: OUTSECS
1018 DOUBLE PRECISION :: SXD, SYD, X0D, Y0D
1020 CHARACTER*120 :: STR2
1021 CHARACTER*512 :: PARTCOM
1023 CHARACTER*30 :: FORMAT1
1024 CHARACTER*30 :: STRSTARTDATE
1025 CHARACTER :: FNAMENC*128, &
1027 CHARACTER,
SAVE :: OLDTIMEID*16 =
'0000000000000000'
1028 CHARACTER,
SAVE :: TIMEID*16 =
'0000000000000000'
1030 LOGICAL :: FLFRQ, FLDIR, FEXIST, FREMOVE
1031 LOGICAL :: CUSTOMFRQ=.false.
1033 LOGICAL :: LTEMP(NGRPP)
1036 TYPE(meta_t) :: META(3)
1043 CALL strace (ient,
'W3EXNC')
1048 ltemp = flg2d(ifi,:)
1049 WRITE (
ndst,9000) ifi, ltemp
1051 WRITE (
ndst,9001) nctype, ix1, ixn, iy1, iyn, vector
1064 ALLOCATE(x1(nxo,nyo), x2(nxo,nyo), xx(nxo,nyo), xy(nxo,nyo))
1065 ALLOCATE(xk(nxo,nyo,nk), xxk(nxo,nyo,nk), xyk(nxo,nyo,nk))
1067 ALLOCATE(mx1(nxo,nyo), mxx(nxo,nyo), myy(nxo,nyo), &
1068 mxy(nxo,nyo), mapout(nxo,nyo))
1069 ALLOCATE(mx1r(nxo,nyo), mxxr(nxo,nyo), myyr(nxo,nyo), mxyr(nxo,nyo))
1072 ALLOCATE(x1(nx+1,ny),x2(nx+1,ny),xx(nx+1,ny),xy(nx+1,ny))
1073 ALLOCATE(xk(nx+1,ny,nk), xxk(nx+1,ny,nk), xyk(nx+1,ny,nk))
1074 ALLOCATE(mx1(nx,ny), mxx(nx,ny), myy(nx,ny), mxy(nx,ny), mapout(nx,ny))
1075 ALLOCATE(mx1r(nx,ny), mxxr(nx,ny), myyr(nx,ny), mxyr(nx,ny))
1077 ALLOCATE(aux1(nsea))
1084 IF( smcgrd .AND. mapstaout)
THEN
1085 WRITE(ndso,*)
"MAPSTA output disabled for SMC grids"
1088 ncvartype = ncvartypei
1094 CALL t2iso(tepoch, epoch_iso)
1095 SELECT CASE(timeunit)
1097 epoch =
'days since ' // epoch_iso
1099 epoch =
'seconds since ' // epoch_iso
1101 print*,
'Unknown time units: ', timeunit
1105 CALL u2d(epoch, epochdate, ierr)
1108 mfill = nf90_fill_short
1109 mfillr = nf90_fill_float
1110 IF (gtype.NE.ungtype)
THEN
1120 IF (s3.GT.0 .AND. s3.LT.4) s3=4
1132 ELSE IF (s3.EQ.10)
THEN
1134 WRITE(format1,
'(A,I1,A,I1,A)')
'(I8.8,A1,I',s5,
'.',s5,
',A1)'
1135 WRITE (timeid,format1) time(1),
'T', &
1136 floor(real(time(2))/nint(10.**(6-s5))),
'Z'
1138 ELSE IF (s3.EQ.8)
THEN
1139 WRITE(format1,
'(A,I1,A,I1,A)')
'(I',s3,
'.',s3,
')'
1140 WRITE (timeid,format1) time(1)
1144 WRITE(format1,
'(A,I1,A,I1,A)')
'(I',s3,
'.',s3,
')'
1145 WRITE (timeid,format1) floor(real(time(1))/nint(10.**(8-s3)))
1148 s1=len_trim(fileprefix)
1150 fnamenc(1:s1)=fileprefix(1:s1)
1151 fnamenc(s1+1:s1+s4) = timeid(1:s4)
1160 IF( smcgrd .AND. (smcotype .EQ. 2) )
CALL mapsta_smc()
1174 IF ( flg2d(ifi,ifj) )
THEN
1177 ipart=tabipart(indexipart)
1189 WRITE (
ndst,9020) idout(ifi,ifj)
1197 IF (ncvartypei.EQ.3) ncvartype=2
1200 IF ( ifi .EQ. 1 .AND. ifj .EQ. 1 )
THEN
1201 CALL s2grid(dw(1:nsea), x1)
1204 ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 2 )
THEN
1211 IF( .NOT. vector )
THEN
1213 tolerance=0.05, conv=
'O')
1216 CALL s2grid(cx(1:nsea), xx)
1217 CALL s2grid(cy(1:nsea), xy)
1221 ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 3 )
THEN
1228 IF( .NOT. vector )
THEN
1230 tolerance=1.0, conv=
'N')
1233 CALL s2grid(ua(1:nsea), xx)
1234 CALL s2grid(ud(1:nsea), xy)
1238 ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 4 )
THEN
1239 CALL s2grid(as(1:nsea), x1)
1242 ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 5 )
THEN
1246 ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 6 )
THEN
1247 CALL s2grid(ice(1:nsea), x1)
1250 ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 7 )
THEN
1252 WHERE ( x1.NE.
undef) x1 = x1*0.1
1255 ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 8 )
THEN
1264 CALL w3s2xy_smc( taua(1:nsea), xx )
1265 CALL w3s2xy_smc( tauadir(1:nsea), xy )
1268 CALL w3s2xy ( nsea, nsea, nx+1, ny, taua(1:nsea) &
1270 CALL w3s2xy ( nsea, nsea, nx+1, ny, tauadir(1:nsea) &
1276 ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 9 )
THEN
1279 CALL w3s2xy_smc(rhoair, x1)
1282 CALL w3s2xy ( nsea, nsea, nx+1, ny, rhoair, mapsf, x1 )
1287 ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 10 )
THEN
1289 WHERE ( x1.NE.
undef) x1 = -log(x1/0.001)/log2
1295 ELSE IF (ifi .EQ. 1 .AND. ifj .EQ. 11 )
THEN
1296 CALL s2grid(iceh(1:nsea), x1)
1302 ELSE IF (ifi .EQ. 1 .AND. ifj .EQ. 12 )
THEN
1303 CALL s2grid(icef(1:nsea), x1)
1308 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 1 )
THEN
1309 IF (ncvartypei.EQ.3) ncvartype=2
1313 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 2 )
THEN
1317 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 3 )
THEN
1321 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 4 )
THEN
1325 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 5 )
THEN
1329 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 6 )
THEN
1333 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 7 )
THEN
1339 CALL s2grid(thm, x1, .true.)
1342 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 8 )
THEN
1346 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 9 )
THEN
1351 CALL s2grid(thp0, x1, .true.)
1354 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 10 )
THEN
1358 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 11 )
THEN
1362 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 12 )
THEN
1366 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 13 )
THEN
1370 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 14 )
THEN
1374 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 15 )
THEN
1378 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 16 )
THEN
1382 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 17 )
THEN
1386 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 18 )
THEN
1388 IF(fp0(i) .NE.
undef)
THEN
1389 aux1(i) = 1.0 / fp0(i)
1398 ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 19 )
THEN
1401 CALL w3s2xy_smc( wnmean, x1 )
1404 CALL w3s2xy ( nsea, nsea, nx+1, ny, wnmean, mapsf, x1 )
1408 ELSE IF ( ifi .EQ. 3 .AND. ifj .EQ. 1 )
THEN
1414 CALL s2grid(ef(:,ik), xx)
1415 IF (ncvartype.EQ.2)
WHERE ( xx.GE.0.) xx = alog10(xx+1e-12)
1420 ELSE IF ( ifi .EQ. 3 .AND. ifj .EQ. 2 )
THEN
1430 CALL s2grid(th1m(:,ik), xx)
1435 ELSE IF ( ifi .EQ. 3 .AND. ifj .EQ. 3 )
THEN
1441 CALL s2grid(sth1m(:,ik), xx)
1446 ELSE IF ( ifi .EQ. 3 .AND. ifj .EQ. 4 )
THEN
1456 CALL s2grid(th2m(:,ik), xx)
1461 ELSE IF ( ifi .EQ. 3 .AND. ifj .EQ. 5 )
THEN
1467 CALL s2grid(sth2m(:,ik), xx)
1472 ELSE IF ( ifi .EQ. 3 .AND. ifj .EQ. 6 )
THEN
1478 CALL s2grid(wn(ik,:), xx)
1483 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 1 )
THEN
1484 CALL s2grid(phs(:,ipart), x1)
1487 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 2 )
THEN
1488 CALL s2grid(ptp(:,ipart), x1)
1491 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 3 )
THEN
1492 CALL s2grid(plp(:,ipart), x1)
1495 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 4 )
THEN
1500 CALL s2grid(pdir(:,ipart), x1, .true.)
1503 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 5 )
THEN
1504 CALL s2grid(psi(:,ipart), x1)
1507 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 6 )
THEN
1508 CALL s2grid(pws(:,ipart), x1)
1511 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 7 )
THEN
1516 CALL s2grid(pthp0(:,ipart), x1, .true.)
1519 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 8 )
THEN
1520 CALL s2grid(pqp(:,ipart), x1)
1523 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 9 )
THEN
1524 CALL s2grid(ppe(:,ipart), x1)
1527 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 10 )
THEN
1528 CALL s2grid(pgw(:,ipart), x1)
1531 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 11 )
THEN
1532 CALL s2grid(psw(:,ipart), x1)
1535 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 12 )
THEN
1536 CALL s2grid(ptm1(:,ipart), x1)
1539 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 13 )
THEN
1540 CALL s2grid(pt1(:,ipart), x1)
1543 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 14 )
THEN
1544 CALL s2grid(pt2(:,ipart), x1)
1547 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 15 )
THEN
1548 CALL s2grid(pep(:,ipart), x1)
1552 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 16 )
THEN
1556 ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 17 )
THEN
1560 ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 1 )
THEN
1563 uabs = sqrt(ust(isea)**2+ustdir(isea)**2)
1564 IF (uabs.GE.10.)
THEN
1573 CALL s2grid(ust(1:nsea), xx)
1574 CALL s2grid(ustdir(1:nsea), xy)
1596 ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 2 )
THEN
1597 CALL s2grid(charn(1:nsea), x1)
1600 ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 3 )
THEN
1602 IF ( cge(isea) .NE.
undef ) &
1603 cge(isea) = 0.001 * cge(isea)
1605 CALL s2grid(cge(1:nsea), x1)
1608 ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 4 )
THEN
1609 IF (ncvartypei.EQ.3) ncvartype=4
1610 CALL s2grid(phiaw(1:nsea), x1)
1613 ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 5 )
THEN
1618 CALL s2grid(tauwix(1:nsea), xx)
1619 CALL s2grid(tauwiy(1:nsea), xy)
1639 ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 6 )
THEN
1644 CALL s2grid(tauwnx(1:nsea), xx)
1645 CALL s2grid(tauwny(1:nsea), xy)
1649 ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 7 )
THEN
1650 CALL s2grid(whitecap(1:nsea,1), x1)
1653 ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 8 )
THEN
1654 CALL s2grid(whitecap(1:nsea,2), x1)
1657 ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 9 )
THEN
1658 CALL s2grid(whitecap(1:nsea,3), x1)
1661 ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 10 )
THEN
1662 CALL s2grid(whitecap(1:nsea,4), x1)
1665 ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 11 )
THEN
1666 CALL s2grid(tws(1:nsea), x1)
1669 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 1 )
THEN
1675 CALL s2grid(sxx(1:nsea), x1)
1676 CALL s2grid(syy(1:nsea), x2)
1677 CALL s2grid(sxy(1:nsea), xy)
1681 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 2 )
THEN
1686 CALL s2grid(tauox(1:nsea), xx)
1687 CALL s2grid(tauoy(1:nsea), xy)
1691 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 3 )
THEN
1692 CALL s2grid(bhd(1:nsea), x1)
1695 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 4 )
THEN
1696 IF (ncvartypei.EQ.3) ncvartype=4
1698 phioc(isea)=min(3000.,phioc(isea))
1700 CALL s2grid(phioc(1:nsea), x1)
1703 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 5 )
THEN
1708 CALL s2grid(tusx(1:nsea), xx)
1709 CALL s2grid(tusy(1:nsea), xy)
1736 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 6 )
THEN
1738 ussx(isea)=max(-0.9998,min(0.9998,ussx(isea)))
1739 ussy(isea)=max(-0.9998,min(0.9998,ussy(isea)))
1745 CALL s2grid(ussx(1:nsea), xx)
1746 CALL s2grid(ussy(1:nsea), xy)
1765 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 7 )
THEN
1767 CALL s2grid(prms(1:nsea), xx)
1768 CALL s2grid(tpms(1:nsea), xy)
1771 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 8 )
THEN
1782 CALL s2grid(us3d(:,ik), xx)
1783 CALL s2grid(us3d(:,nk+ik), xy)
1789 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 9 )
THEN
1795 CALL s2grid(p2sms(:,ik), xx)
1797 IF (ncvartype.EQ.2)
THEN
1798 WHERE ( xx.GE.0.) xx = alog10(xx*(
dwat*
grav)**2+1e-12)
1800 WHERE ( xx.GE.0.) xx = xx*(
dwat*
grav)**2
1807 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 10 )
THEN
1812 CALL s2grid(tauice(1:nsea,1), xx)
1813 CALL s2grid(tauice(1:nsea,2), xy)
1817 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 11 )
THEN
1818 IF (ncvartypei.EQ.3) ncvartype=4
1819 CALL s2grid(phice(1:nsea), x1)
1822 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 12 )
THEN
1825 IF (usspf(1)==1)
THEN
1836 CALL s2grid(ussp(:,ik), xx)
1837 CALL s2grid(ussp(:,nk+ik), xy)
1843 ELSE IF ( ifi .EQ. 6 .AND. ifj .EQ. 13 )
THEN
1850 CALL w3s2xy_smc( tauocx(1:nsea), xx )
1851 CALL w3s2xy_smc( tauocy(1:nsea), xy )
1854 CALL w3s2xy ( nsea, nsea, nx+1, ny, tauocx(1:nsea) &
1856 CALL w3s2xy ( nsea, nsea, nx+1, ny, tauocy(1:nsea) &
1862 ELSE IF ( ifi .EQ. 7 .AND. ifj .EQ. 1 )
THEN
1868 CALL s2grid(aba(1:nsea), xx)
1869 CALL s2grid(abd(1:nsea), xy)
1873 ELSE IF ( ifi .EQ. 7 .AND. ifj .EQ. 2 )
THEN
1879 CALL s2grid(uba(1:nsea), xx)
1880 CALL s2grid(ubd(1:nsea), xy)
1884 ELSE IF ( ifi .EQ. 7 .AND. ifj .EQ. 3 )
THEN
1888 bedforms(1:nsea,3),
angld)
1890 CALL s2grid(bedforms(1:nsea,1), x1)
1891 CALL s2grid(bedforms(1:nsea,2), x2)
1892 CALL s2grid(bedforms(1:nsea,3), xy)
1896 ELSE IF ( ifi .EQ. 7 .AND. ifj .EQ. 4 )
THEN
1897 CALL s2grid(phibbl(1:nsea), x1)
1900 ELSE IF ( ifi .EQ. 7 .AND. ifj .EQ. 5 )
THEN
1904 taubbl(1:nsea,2),
angld)
1906 CALL s2grid(taubbl(1:nsea,1), xx)
1907 CALL s2grid(taubbl(1:nsea,2), xy)
1911 ELSE IF ( ifi .EQ. 8 .AND. ifj .EQ. 1 )
THEN
1921 ELSE IF ( ifi .EQ. 8 .AND. ifj .EQ. 2 )
THEN
1931 ELSE IF ( ifi .EQ. 8 .AND. ifj .EQ. 3 )
THEN
1937 IF ( mssd(isea) .NE.
undef )
THEN
1938 mssd(isea) = mod( 630. -
rade*mssd(isea) , 180. )
1944 ELSE IF ( ifi .EQ. 8 .AND. ifj .EQ. 4 )
THEN
1950 IF ( mscd(isea) .NE.
undef )
THEN
1951 mscd(isea) = mod( 630. -
rade*mscd(isea) , 180. )
1957 ELSE IF ( ifi .EQ. 8 .AND. ifj .EQ. 5 )
THEN
1961 ELSE IF ( ifi .EQ. 8 .AND. ifj .EQ. 6 )
THEN
1965 ELSE IF ( ifi .EQ. 8 .AND. ifj .EQ. 7 )
THEN
1969 ELSE IF ( ifi .EQ. 8 .AND. ifj .EQ. 8 )
THEN
1973 ELSE IF ( ifi .EQ. 8 .AND. ifj .EQ. 9 )
THEN
1977 ELSE IF ( ifi .EQ. 9 .AND. ifj .EQ. 1 )
THEN
1979 IF ( dtdyn(isea) .NE.
undef )
THEN
1980 dtdyn(isea) = dtdyn(isea) / 60.
1986 ELSE IF ( ifi .EQ. 9 .AND. ifj .EQ. 2 )
THEN
1990 ELSE IF ( ifi .EQ. 9 .AND. ifj .EQ. 3 )
THEN
1991 IF (ncvartypei.EQ.3) ncvartype=4
1992 CALL s2grid(cflxymax, x1)
1995 ELSE IF ( ifi .EQ. 9 .AND. ifj .EQ. 4 )
THEN
1996 IF (ncvartypei.EQ.3) ncvartype=4
1997 CALL s2grid(cflthmax, x1)
2000 ELSE IF ( ifi .EQ. 9 .AND. ifj .EQ. 5 )
THEN
2001 IF (ncvartypei.EQ.3) ncvartype=4
2005 ELSE IF ( ifi .EQ. 10 )
THEN
2007 CALL s2grid(usero(:,ifj), x1)
2009 WRITE (ndse,999) ifi, ifj
2016 meta(i) = getmeta(ifi, ifj, icomp=i, ipart=ipart)
2022 IF( .NOT. smcgrd )
THEN
2025 mapout(ix,iy)=int2(mapsta(iy,ix) + 8*mapst2(iy,ix))
2026 IF ( mapsta(iy,ix) .EQ. 0 )
THEN
2032 IF ( x1(ix,iy) .EQ.
undef )
THEN
2037 IF ( x2(ix,iy) .EQ.
undef )
THEN
2049 s2=len_trim(meta(1)%ENAME)
2050 s1=len_trim(fileprefix)+s4
2051 fnamenc(s1+1:128)=
' '
2052 fnamenc(s1+1:s1+1) =
'_'
2056 IF (together.AND.(.NOT.flfrq))
THEN
2061 fnamenc(s1+2:s1+s2) = meta(1)%ENAME(2:s2)
2064 fnamenc(s1+s2+1:s1+s2+3) =
'.nc'
2065 fnamenc(s1+s2+4:s1+s2+6) =
' '
2076 IF (gtype.NE.ungtype)
THEN
2079 IF( smcotype .EQ. 1 )
THEN
2106 IF (together.AND.(.NOT.flfrq))
THEN
2107 oldncid = ncids(1,1,1)
2109 oldncid = ncids(ifi,ifj,ipart+1)
2115 INQUIRE(
file=fnamenc, exist=fexist)
2119 IF (index(timeid,oldtimeid).EQ.0)
THEN
2121 IF (together.AND.(.NOT.flfrq).AND.ncid.EQ.0) fremove = .true.
2123 IF (.NOT.together.OR.flfrq) fremove = .true.
2127 OPEN(unit=1234, iostat=iret,
file=fnamenc, status=
'old')
2128 IF (iret == 0)
CLOSE(1234, status=
'delete')
2137 IF (.NOT.fexist)
THEN
2138 IF (index(
'0000000000000000',oldtimeid).EQ.0 .AND. index(timeid,oldtimeid).EQ.0)
THEN
2139 iret = nf90_redef(oldncid)
2141 IF(fl_default_gbl_meta)
THEN
2142 iret=nf90_put_att(oldncid,nf90_global,
'stop_date',strstopdate)
2145 iret=nf90_close(oldncid)
2153 IF (.NOT.fexist)
THEN
2176 CALL w3crnc(fnamenc,ncid,dimid,dimln,varid, &
2177 extradim,nctype,mapstaout)
2181 IF (together.AND.(.NOT.flfrq))
THEN
2184 ncids(ifi,ifj,ipart+1)=ncid
2188 IF (gtype.EQ.clgtype)
THEN
2189 IF (.NOT.
ALLOCATED(lon2d))
ALLOCATE(lon2d(nx,ny),lat2d(nx,ny))
2190 lon2d=transpose(xgrd)
2191 lat2d=transpose(ygrd)
2192 IF(fl_default_gbl_meta)
THEN
2193 iret=nf90_put_att(ncid,nf90_global, &
2194 'latitude_resolution',
'n/a')
2196 iret=nf90_put_att(ncid,nf90_global, &
2197 'longitude_resolution',
'n/a')
2204 IF(smcotype .EQ. 1)
THEN
2206 IF(.NOT.
ALLOCATED(lon))
ALLOCATE(lon(smcnout))
2207 IF(.NOT.
ALLOCATED(lat))
ALLOCATE(lat(smcnout))
2208 IF(.NOT.
ALLOCATED(smccx))
ALLOCATE(smccx(smcnout))
2209 IF(.NOT.
ALLOCATED(smccy))
ALLOCATE(smccy(smcnout))
2212 IF(.NOT.
ALLOCATED(lon))
ALLOCATE(lon(nxo))
2213 IF(.NOT.
ALLOCATED(lat))
ALLOCATE(lat(nyo))
2223 IF(.NOT.
ALLOCATED(lon2deq))
ALLOCATE(lon2deq(rtdnx,rtdny))
2224 IF(.NOT.
ALLOCATED(lat2deq))
ALLOCATE(lat2deq(rtdnx,rtdny))
2231 IF(.NOT.
ALLOCATED(lon2d))
THEN
2237 ALLOCATE(lon2d(rtdnx,rtdny), lat2d(rtdnx,rtdny))
2238 ALLOCATE(angld2d(rtdnx,rtdny))
2243 IF (.NOT.
ALLOCATED(lon))
ALLOCATE(lon(nx))
2246 IF ( rtdl .AND. .NOT.
ALLOCATED(lon2d)) &
2247 ALLOCATE(lon2d(nx,ny),lon2deq(nx,ny),angld2d(nx,ny))
2249 IF (.NOT.
ALLOCATED(lat))
THEN
2251 IF (gtype.EQ.rlgtype)
THEN
2255 IF ( rtdl .AND. .NOT.
ALLOCATED(lat2d)) &
2256 ALLOCATE(lat2d(nx,ny),lat2deq(nx,ny))
2270 IF (gtype.EQ.rlgtype .OR. gtype.EQ.smctype)
THEN
2274 IF( smcotype .EQ. 1 )
THEN
2278 lon(i) = (x0-0.5*sx) + (ijkcel(1,j) + 0.5 * ijkcel(3,j)) * dlon
2279 lat(i) = (y0-0.5*sy) + (ijkcel(2,j) + 0.5 * ijkcel(4,j)) * dlat
2280 smccx(i) = ijkcel(3,j)
2281 smccy(i) = ijkcel(4,j)
2290 CALL w3eqtoll(lat, lon, lat2d(:,1), lon2d(:,1), &
2296 sxd=dble(0.000001d0*dnint(1d6*(dble(dxo)) ))
2297 syd=dble(0.000001d0*dnint(1d6*(dble(dyo)) ))
2298 x0d=dble(0.000001d0*dnint(1d6*(dble(sxo)) ))
2299 y0d=dble(0.000001d0*dnint(1d6*(dble(syo)) ))
2301 lon(i)=real(x0d+sxd*dble(i-1))
2304 lon2deq(i,:) = lon(i)
2309 lat(i)=real(y0d+syd*dble(i-1))
2312 lat2deq(:,i) = lat(i)
2316 WRITE(str2,
'(F12.7)') dyo
2318 IF(fl_default_gbl_meta)
THEN
2319 iret=nf90_put_att(ncid,nf90_global, &
2320 'latitude_resolution', trim(str2))
2321 WRITE(str2,
'(F12.7)') dxo
2323 iret=nf90_put_att(ncid,nf90_global, &
2324 'longitude_resolution',trim(str2))
2333 CALL w3eqtoll(lat2deq, lon2deq, lat2d, lon2d, &
2340 sxd=dble(0.000001d0*dnint(1d6*(dble(sx)) ))
2341 syd=dble(0.000001d0*dnint(1d6*(dble(sy)) ))
2342 x0d=dble(0.000001d0*dnint(1d6*(dble(x0)) ))
2343 y0d=dble(0.000001d0*dnint(1d6*(dble(y0)) ))
2345 lon(i)=real(x0d+sxd*dble(i-1))
2348 lat(i)=real(y0d+syd*dble(i-1))
2359 CALL w3eqtoll(lat2deq, lon2deq, lat2d, lon2d, &
2363 IF(fl_default_gbl_meta)
THEN
2364 WRITE(str2,
'(F12.0)') sy
2366 iret=nf90_put_att(ncid,nf90_global, &
2367 'latitude_resolution', trim(str2))
2369 WRITE(str2,
'(F12.0)') sx
2371 iret=nf90_put_att(ncid,nf90_global, &
2372 'longitude_resolution',trim(str2))
2379 IF (gtype.EQ.ungtype)
THEN
2384 IF(fl_default_gbl_meta)
THEN
2385 iret=nf90_put_att(ncid,nf90_global, &
2386 'latitude_resolution',
'n/a')
2388 iret=nf90_put_att(ncid,nf90_global, &
2389 'longitude_resolution',
'n/a')
2395 IF(fl_default_gbl_meta)
THEN
2397 WRITE(str2,
'(F12.0)') minval(lat)
2399 WRITE(str2,
'(F12.0)') minval(ygrd)
2402 iret=nf90_put_att(ncid,nf90_global, &
2403 'southernmost_latitude',trim(str2))
2407 WRITE(str2,
'(F12.0)') maxval(lat)
2409 WRITE(str2,
'(F12.0)') maxval(ygrd)
2412 iret=nf90_put_att(ncid,nf90_global, &
2413 'northernmost_latitude',trim(str2))
2417 WRITE(str2,
'(F12.0)') minval(lon)
2419 WRITE(str2,
'(F12.0)') minval(xgrd)
2422 iret=nf90_put_att(ncid,nf90_global, &
2423 'westernmost_longitude',trim(str2))
2428 WRITE(str2,
'(F12.0)') maxval(lon)
2430 WRITE(str2,
'(F12.0)') maxval(xgrd)
2433 iret=nf90_put_att(ncid,nf90_global, &
2434 'easternmost_longitude',trim(str2))
2436 iret=nf90_put_att(ncid,nf90_global, &
2437 'minimum_altitude',
'-12000 m')
2439 iret=nf90_put_att(ncid,nf90_global, &
2440 'maximum_altitude',
'9000 m')
2442 iret=nf90_put_att(ncid,nf90_global, &
2443 'altitude_resolution',
'n/a')
2448 iret=nf90_put_att(ncid,nf90_global, &
2449 'grid_north_pole_latitude',
polat)
2450 iret=nf90_put_att(ncid,nf90_global, &
2451 'grid_north_pole_longitude',
polon)
2456 CALL t2d(time,startdate,ierr)
2457 WRITE(strstartdate,
'(I4.4,A,4(I2.2,A),I2.2)') startdate(1),
'-',startdate(2),
'-', &
2458 startdate(3),
' ',startdate(5),
':',startdate(6),
':',startdate(7)
2461 iret = nf90_enddef(ncid)
2467 IF (gtype.EQ.rlgtype .OR. gtype.EQ.smctype)
THEN
2470 iret=nf90_put_var(ncid,varid(1),lon(:))
2472 iret=nf90_put_var(ncid,varid(2),lat(:))
2474 IF(smcotype .EQ. 1)
THEN
2476 iret=nf90_put_var(ncid,varid(5),smccx)
2478 iret=nf90_put_var(ncid,varid(6),smccy)
2483 iret=nf90_put_var(ncid,varid(1),lon(ix1:ixn))
2485 iret=nf90_put_var(ncid,varid(2),lat(iy1:iyn))
2490 iret=nf90_put_var(ncid,varid(7),lon2d(ix1:ixn,iy1:iyn))
2492 iret=nf90_put_var(ncid,varid(8),lat2d(ix1:ixn,iy1:iyn))
2499 IF (gtype.EQ.clgtype)
THEN
2500 iret=nf90_put_var(ncid,varid(1),lon2d(ix1:ixn,iy1:iyn))
2502 iret=nf90_put_var(ncid,varid(2),lat2d(ix1:ixn,iy1:iyn))
2507 IF (gtype.EQ.ungtype)
THEN
2508 iret=nf90_put_var(ncid,varid(1),lon(ix1:ixn))
2510 iret=nf90_put_var(ncid,varid(2),lat(ix1:ixn))
2515 IF (extradim.EQ.1)
THEN
2516 ALLOCATE(freq(i2f-i1f+1))
2524 freq(i)=sig(i1f-1+i)*
tpiinv
2527 iret=nf90_put_var(ncid,varid(10),freq)
2533 IF (gtype.EQ.ungtype)
THEN
2534 iret=nf90_put_var(ncid,varid(4),trigp)
2544 IF (gtype.NE.ungtype)
THEN
2545 iret=nf90_put_var(ncid,varid(20),mapout(ix1:ixn,iy1:iyn), &
2546 (/start(1:2)/),(/count(1:2)/))
2548 iret=nf90_put_var(ncid,varid(20),mapout(ix1:ixn,1),(/start(1)/),(/count(1)/))
2555 IF(timeunit .EQ.
'S')
THEN
2556 outsecs = tsubsec(epochdate, refdate)
2557 iret = nf90_put_var(ncid, varid(12), outsecs)
2559 outjulday = tsub(epochdate, refdate)
2560 iret = nf90_put_var(ncid, varid(12), outjulday)
2565 WRITE (ndso,973) fnamenc
2569 iret = nf90_redef(ncid)
2573 IF (coordtype.EQ.1)
THEN
2574 IF (ncvartype.EQ.2)
THEN
2576 IF( smcgrd .AND. smcotype .EQ. 1 )
THEN
2578 iret = nf90_def_var(ncid,meta(i)%varnm, nf90_short, (/dimid(2), dimid(4+extradim)/), varid(ivar))
2581 iret = nf90_def_var(ncid,meta(i)%varnm, nf90_short, dimid(2:4+extradim), varid(ivar))
2586 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(ivar), 1, 1, deflate)
2590 IF( smcgrd .AND. smcotype .EQ. 1 )
THEN
2592 iret = nf90_def_var(ncid,meta(i)%varnm, nf90_float, (/dimid(2), dimid(4+extradim)/), varid(ivar))
2595 iret = nf90_def_var(ncid,meta(i)%varnm, nf90_float, dimid(2:4+extradim), varid(ivar))
2600 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(ivar), 1, 1, deflate)
2604 dimfield(1)=dimid(2)
2605 dimfield(2)=dimid(4)
2606 dimfield(3)=dimid(5)
2607 IF (ncvartype.EQ.2)
THEN
2608 iret = nf90_def_var(ncid,meta(i)%VARNM, nf90_short, dimfield(1:2+extradim), varid(ivar))
2610 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(ivar), 1, 1, deflate)
2613 iret = nf90_def_var(ncid,meta(i)%VARNM, nf90_float, dimfield(1:2+extradim), varid(ivar))
2615 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(ivar), 1, 1, deflate)
2621 IF(ncvartype .GT. 2) meta(i)%FSC = 1.0
2624 CALL write_meta(ncid, varid(ivar), meta(i), iret)
2641 IF(fl_default_gbl_meta)
THEN
2642 iret=nf90_put_att(ncid,nf90_global,
'start_date',strstartdate)
2646 iret = nf90_enddef(ncid)
2657 IF (gtype.EQ.ungtype)
THEN
2658 iret=nf90_inq_varid(ncid,
'tri', varid(4))
2665 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
2666 iret=nf90_inq_dimid(ncid,
'seapoint', dimid(2))
2669 iret=nf90_inq_dimid(ncid,
'longitude', dimid(2))
2670 iret=nf90_inq_dimid(ncid,
'latitude', dimid(3))
2674 iret=nf90_inq_varid(ncid,
'longitude', varid(1))
2675 iret=nf90_inq_varid(ncid,
'latitude', varid(2))
2678 iret=nf90_inq_dimid(ncid,
'x', dimid(2))
2679 iret=nf90_inq_varid(ncid,
'x', varid(1))
2680 iret=nf90_inq_dimid(ncid,
'y', dimid(3))
2681 iret=nf90_inq_varid(ncid,
'y', varid(2))
2686 iret=nf90_inq_dimid(ncid,
'time', dimid(4+extradim))
2687 iret=nf90_inquire_dimension(ncid, dimid(4+extradim),len=n)
2689 iret=nf90_inq_varid(ncid,
'time', varid(3))
2691 iret = nf90_inq_varid(ncid,
'forecast_period', varid(11))
2695 IF (extradim.EQ.1) iret=nf90_inq_dimid(ncid,
'f', dimid(4))
2703 IF((together .AND. ifi.EQ.i1 .AND. ifj.EQ.j1 .AND. ipart.EQ.tabipart(1)) &
2704 .OR.(.NOT.together).OR.flfrq) n=n+1
2710 iret = nf90_redef(ncid)
2716 IF (coordtype.EQ.1)
THEN
2717 IF (ncvartype.EQ.2)
THEN
2719 IF( smcgrd .AND. smcotype .EQ. 1 )
THEN
2721 iret = nf90_def_var(ncid,meta(i)%varnm, nf90_short, (/dimid(2), dimid(4+extradim)/), varid(ivar))
2724 iret = nf90_def_var(ncid,meta(i)%varnm, nf90_short, dimid(2:4+extradim), varid(ivar))
2729 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(ivar), 1, 1, deflate)
2732 IF( smcgrd .AND. smcotype .EQ. 1 )
THEN
2734 iret = nf90_def_var(ncid,meta(i)%varnm, nf90_float, (/dimid(2), dimid(4+extradim)/), varid(ivar))
2737 iret = nf90_def_var(ncid,meta(i)%varnm, nf90_float, dimid(2:4+extradim), varid(ivar))
2742 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(ivar), 1, 1, deflate)
2746 dimfield(1)=dimid(2)
2747 dimfield(2)=dimid(4)
2748 dimfield(3)=dimid(5)
2749 IF (ncvartype.EQ.2)
THEN
2750 iret = nf90_def_var(ncid,meta(i)%varnm, nf90_short, dimfield(1:2+extradim), varid(ivar))
2752 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(ivar), 1, 1, deflate)
2755 iret = nf90_def_var(ncid,meta(i)%varnm, nf90_float, dimfield(1:2+extradim), varid(ivar))
2757 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(ivar), 1, 1, deflate)
2763 IF(ncvartype .GT. 2) meta(i)%FSC = 1.0
2766 CALL write_meta(ncid, varid(ivar), meta(i), iret)
2781 iret = nf90_enddef(ncid)
2786 iret=nf90_redef(ncid)
2792 iret=nf90_inq_varid(ncid, meta(i)%VARNM, varid(ivar))
2795 iret=nf90_enddef(ncid)
2802 CALL t2d(time,curdate,ierr)
2803 WRITE(ndso,
'(A,A9,A,I6,A,I4,A,I2.2,A,I2.2,A,I2.2,A,I2.2,A,I2.2,2A)') &
2804 'Writing new record ', meta(1)%ENAME(2:) ,
'number ',n, &
2805 ' for ',curdate(1),
':',curdate(2),
':',curdate(3),
'T',curdate(5),&
2806 ':',curdate(6),
':',curdate(7),
' in file ',trim(fnamenc)
2817 start(3+1-coordtype+extradim)=n
2824 count1d(1)=ixn-ix1+1
2828 IF((ifi.EQ.i1.AND.ifj.EQ.j1.AND.together) &
2829 .OR.(.NOT.together).OR.flfrq)
THEN
2832 IF(timeunit .EQ.
'S')
THEN
2834 outsecs = tsubsec(epochdate,curdate)
2835 iret = nf90_put_var(ncid, varid(3), outsecs, (/n/))
2838 outjulday = tsub(epochdate,curdate)
2839 iret = nf90_put_var(ncid, varid(3), outjulday, (/n/))
2845 outsecs = tsubsec(refdate, curdate)
2846 iret = nf90_put_var(ncid, varid(11), outsecs, (/n/))
2854 IF (ncvartype.EQ.2)
THEN
2855 IF ( nfield.EQ.3 )
THEN
2858 IF ( x1(ix,iy) .EQ.
undef )
THEN
2863 mxx(ix,iy) = nint(x1(ix,iy)/meta(1)%FSC)
2864 myy(ix,iy) = nint(x2(ix,iy)/meta(2)%FSC)
2865 mxy(ix,iy) = nint(xy(ix,iy)/meta(3)%FSC)
2870 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
2871 iret=nf90_put_var(ncid,varid(ivar1+1), &
2872 mxx(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
2874 iret=nf90_put_var(ncid,varid(ivar1+2), &
2875 myy(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
2877 iret=nf90_put_var(ncid,varid(ivar1+3), &
2878 mxy(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
2882 iret=nf90_put_var(ncid,varid(ivar1+1), &
2883 mxx(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
2885 iret=nf90_put_var(ncid,varid(ivar1+2), &
2886 myy(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
2888 iret=nf90_put_var(ncid,varid(ivar1+3), &
2889 mxy(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
2895 ELSE IF (nfield.EQ.2 )
THEN
2897 IF (extradim.EQ.0)
THEN
2900 IF ( xx(ix,iy) .EQ.
undef )
THEN
2904 mxx(ix,iy) = nint(xx(ix,iy)/meta(1)%FSC)
2905 myy(ix,iy) = nint(xy(ix,iy)/meta(2)%FSC)
2910 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
2911 iret=nf90_put_var(ncid,varid(ivar1+1), &
2912 mxx(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
2914 iret=nf90_put_var(ncid,varid(ivar1+2), &
2915 myy(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
2919 iret=nf90_put_var(ncid,varid(ivar1+1), &
2920 mxx(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
2922 iret=nf90_put_var(ncid,varid(ivar1+2), &
2923 myy(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
2930 start(3+1-coordtype)=0
2932 start(3+1-coordtype)=start(3+1-coordtype)+1
2935 IF ( xxk(ix,iy,ik) .EQ.
undef )
THEN
2939 mxx(ix,iy) = nint(xxk(ix,iy,ik)/meta(1)%FSC)
2940 myy(ix,iy) = nint(xyk(ix,iy,ik)/meta(2)%FSC)
2945 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
2946 iret=nf90_put_var(ncid,varid(ivar1+1), &
2947 mxx(ix1:ixn,iy1:iyn),(/start(1), start(3), start(4)/), &
2948 (/count(1), count(3), count(4)/))
2950 iret=nf90_put_var(ncid,varid(ivar1+2), &
2951 mxy(ix1:ixn,iy1:iyn),(/start(1), start(3), start(4)/), &
2952 (/count(1), count(3), count(4)/))
2956 iret=nf90_put_var(ncid,varid(ivar1+1), &
2957 mxx(ix1:ixn,iy1:iyn),(/start(1:4)/),(/count(1:4)/))
2959 iret=nf90_put_var(ncid,varid(ivar1+2), &
2960 mxx(ix1:ixn,iy1:iyn),(/start(1:4)/),(/count(1:4)/))
2970 IF (extradim.EQ.0)
THEN
2973 IF ( x1(ix,iy) .EQ.
undef )
THEN
2976 mx1(ix,iy) = nint(x1(ix,iy)/meta(1)%FSC)
2981 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
2982 iret=nf90_put_var(ncid,varid(ivar1+1), &
2983 mx1(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
2987 iret=nf90_put_var(ncid,varid(ivar1+1), &
2988 mx1(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
2995 start(3+1-coordtype)=0
2997 start(3+1-coordtype)=start(3+1-coordtype)+1
3000 IF ( xk(ix,iy,ik) .EQ.
undef )
THEN
3003 mx1(ix,iy) = nint(xk(ix,iy,ik)/meta(1)%FSC)
3008 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
3009 iret=nf90_put_var(ncid,varid(ivar1+1), &
3010 mx1(ix1:ixn,iy1:iyn),(/start(1), start(3), start(4)/), &
3011 (/count(1), count(3), count(4)/))
3015 iret=nf90_put_var(ncid,varid(ivar1+1), &
3016 mx1(ix1:ixn,iy1:iyn),(/start(1:4)/),(/count(1:4)/))
3028 IF ( nfield.EQ.3 )
THEN
3031 IF ( x1(ix,iy) .EQ.
undef )
THEN
3032 mxxr(ix,iy) = mfillr
3033 myyr(ix,iy) = mfillr
3034 mxyr(ix,iy) = mfillr
3036 mxxr(ix,iy) = x1(ix,iy)
3037 myyr(ix,iy) = x2(ix,iy)
3038 mxyr(ix,iy) = xy(ix,iy)
3043 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
3044 iret=nf90_put_var(ncid,varid(ivar1+1), &
3045 mxxr(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
3047 iret=nf90_put_var(ncid,varid(ivar1+2), &
3048 myyr(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
3050 iret=nf90_put_var(ncid,varid(ivar1+3), &
3051 mxyr(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
3055 iret=nf90_put_var(ncid,varid(ivar1+1), &
3056 mxxr(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
3058 iret=nf90_put_var(ncid,varid(ivar1+2), &
3059 myyr(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
3061 iret=nf90_put_var(ncid,varid(ivar1+3), &
3062 mxyr(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
3068 ELSE IF (nfield.EQ.2 )
THEN
3070 IF (extradim.EQ.0)
THEN
3073 IF ( xx(ix,iy) .EQ.
undef )
THEN
3074 mxxr(ix,iy) = mfillr
3075 myyr(ix,iy) = mfillr
3077 mxxr(ix,iy) = xx(ix,iy)
3078 myyr(ix,iy) = xy(ix,iy)
3083 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
3084 iret=nf90_put_var(ncid,varid(ivar1+1), &
3085 mxxr(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
3087 iret=nf90_put_var(ncid,varid(ivar1+2), &
3088 myyr(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
3092 iret=nf90_put_var(ncid,varid(ivar1+1), &
3093 mxxr(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
3095 iret=nf90_put_var(ncid,varid(ivar1+2), &
3096 myyr(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
3103 start(4-coordtype)=0
3105 start(4-coordtype)=start(4-coordtype)+1
3108 IF ( xxk(ix,iy,ik) .EQ.
undef )
THEN
3109 mxxr(ix,iy) = mfillr
3110 myyr(ix,iy) = mfillr
3112 mxxr(ix,iy) = xxk(ix,iy,ik)
3113 myyr(ix,iy) = xyk(ix,iy,ik)
3118 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
3119 iret=nf90_put_var(ncid,varid(ivar1+1), &
3120 mxxr(ix1:ixn,iy1:iyn),(/start(1), start(3), start(4)/), &
3121 (/count(1), count(3), count(4)/))
3123 iret=nf90_put_var(ncid,varid(ivar1+2), &
3124 myyr(ix1:ixn,iy1:iyn),(/start(1), start(3), start(4)/), &
3125 (/count(1), count(3), count(4)/))
3129 iret=nf90_put_var(ncid,varid(ivar1+1), &
3130 mxxr(ix1:ixn,iy1:iyn),(/start(1:4)/),(/count(1:4)/))
3132 iret=nf90_put_var(ncid,varid(ivar1+2), &
3133 myyr(ix1:ixn,iy1:iyn),(/start(1:4)/),(/count(1:4)/))
3143 IF (extradim.EQ.0)
THEN
3146 IF ( x1(ix,iy) .EQ.
undef )
THEN
3147 mx1r(ix,iy) = mfillr
3149 mx1r(ix,iy) = x1(ix,iy)
3154 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
3155 iret=nf90_put_var(ncid,varid(ivar1+1), &
3156 mx1r(ix1:ixn,iy1:iyn),(/start(1), start(3)/),(/count(1), count(3)/))
3160 iret=nf90_put_var(ncid,varid(ivar1+1), &
3161 mx1r(ix1:ixn,iy1:iyn),(/start(1:3)/),(/count(1:3)/))
3168 start(4-coordtype)=0
3170 start(4-coordtype)=start(4-coordtype)+1
3173 IF ( xk(ix,iy,ik) .EQ.
undef )
THEN
3174 mx1r(ix,iy) = mfillr
3176 mx1r(ix,iy) = xk(ix,iy,ik)
3181 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
3182 iret=nf90_put_var(ncid,varid(ivar1+1), &
3183 mx1r(ix1:ixn,iy1:iyn),(/start(1), start(3), start(4)/), &
3184 (/count(1), count(3), count(4)/))
3188 iret=nf90_put_var(ncid,varid(ivar1+1), &
3189 mx1r(ix1:ixn,iy1:iyn),(/start(1:4)/),(/count(1:4)/))
3207 IF (ifi .EQ. 4 .AND. ifj .LE. noge(ifi) - 2)
THEN
3209 IF (indexipart.LT.nbipart)
THEN
3210 indexipart=indexipart+1
3211 IF (tabipart(indexipart).EQ.-1)
GOTO 560
3212 ipart=tabipart(indexipart)
3224 DEALLOCATE(x1, x2, xx, xy, xk, xxk, xyk)
3225 DEALLOCATE(mx1, mxx, myy, mxy, mapout)
3226 DEALLOCATE(mx1r, mxxr, myyr, mxyr)
3228 IF (
ALLOCATED(lon))
DEALLOCATE(lon, lat)
3229 IF (
ALLOCATED(lon2d))
DEALLOCATE(lon2d, lat2d)
3231 IF (
ALLOCATED(lon2deq))
DEALLOCATE(lat2deq, lon2deq, angld2d)
3242 973
FORMAT (
'NEW NETCDF FILE WAS CREATED ',a)
3243 999
FORMAT (/
' *** WAVEWATCH III ERROR IN W3EXNC :'/ &
3244 ' PLEASE UPDATE FIELDS !!! '/ &
3245 ' IFI = ',i2,
'- IFJ = ',i2/)
3248 9000
FORMAT (
' TEST W3EXNC : FLAGS :',i3,2x,20l2)
3249 9001
FORMAT (
' TEST W3EXNC : ITPYE :',i4/ &
3256 9012
FORMAT (
' TEST W3EXNC : BLOK PARS : ',3i4)
3257 9014
FORMAT (
' BASE NAME : ',a)
3261 9020
FORMAT (
' TEST W3EXNC : OUTPUT FIELD : ',a)
3288 SUBROUTINE w3crnc (NCFILE, NCID, DIMID, DIMLN, VARID, &
3289 EXTRADIM, NCTYPE, MAPSTAOUT )
3303 INTEGER,
INTENT(IN) :: EXTRADIM
3304 INTEGER,
INTENT(IN) :: NCTYPE
3305 CHARACTER*(*),
INTENT(IN) :: NCFILE
3306 INTEGER,
INTENT(OUT) :: NCID
3307 INTEGER,
INTENT(OUT) :: DIMID(6)
3308 INTEGER,
INTENT(IN) :: DIMLN(6)
3309 INTEGER,
INTENT(OUT) :: VARID(300)
3310 LOGICAL,
INTENT(IN) :: MAPSTAOUT
3315 INTEGER :: IVAR,IRET,ICODE,STRL,STRL2
3316 INTEGER :: DIMTRI(2)
3317 INTEGER :: DEFLATE=1
3319 CHARACTER :: ATTNAME*120,ATTVAL*120
3325 IF(nctype.EQ.3) iret = nf90_create(trim(ncfile), nf90_clobber, ncid)
3326 IF(nctype.EQ.4) iret = nf90_create(trim(ncfile), nf90_netcdf4, ncid)
3331 iret = nf90_def_dim(ncid,
'level', dimln(1), dimid(1))
3336 IF (gtype.NE.ungtype)
THEN
3339 IF(smcgrd .AND. smcotype .EQ. 1)
THEN
3341 iret = nf90_def_dim(ncid,
'seapoint', dimln(2), dimid(2))
3345 iret = nf90_def_dim(ncid,
'longitude', dimln(2), dimid(2))
3346 iret = nf90_def_dim(ncid,
'latitude', dimln(3), dimid(3))
3351 iret = nf90_def_dim(ncid,
'x', dimln(2), dimid(2))
3352 iret = nf90_def_dim(ncid,
'y', dimln(3), dimid(3))
3359 iret = nf90_def_dim(ncid,
'node', dimln(2), dimid(2))
3360 iret = nf90_def_dim(ncid,
'element', dimln(3), dimid(3))
3367 IF (extradim.EQ.1)
THEN
3368 iret = nf90_def_dim(ncid,
'f', dimln(4), dimid(4))
3372 iret = nf90_def_dim(ncid,
'time',nf90_unlimited, dimid(4+extradim))
3375 IF (gtype.EQ.ungtype)
THEN
3376 iret = nf90_def_dim(ncid,
'noel',3, dimid(5+extradim))
3386 IF (gtype.EQ.rlgtype .OR. gtype.EQ.smctype)
THEN
3389 IF(smcotype .EQ. 1)
THEN
3391 iret = nf90_def_var(ncid,
'longitude', nf90_float, dimid(2), varid(1))
3393 iret = nf90_def_var(ncid,
'latitude', nf90_float, dimid(2), varid(2))
3398 coords_attr = trim(coords_attr) //
" latitude longitude"
3401 iret = nf90_def_var(ncid,
'cx', nf90_short, dimid(2), varid(5))
3403 iret = nf90_put_att(ncid, varid(5),
'long_name', &
3404 'longitude cell size factor')
3405 iret = nf90_put_att(ncid, varid(5),
'valid_min', 1)
3406 iret = nf90_put_att(ncid, varid(5),
'valid_max', 256)
3408 iret = nf90_def_var(ncid,
'cy', nf90_short, dimid(2), varid(6))
3410 iret = nf90_put_att(ncid, varid(6),
'long_name', &
3411 'latitude cell size factor')
3412 iret = nf90_put_att(ncid, varid(6),
'valid_min', 1)
3413 iret = nf90_put_att(ncid, varid(6),
'valid_max', 256)
3416 iret = nf90_def_var(ncid,
'longitude', nf90_float, dimid(2), varid(1))
3418 iret = nf90_def_var(ncid,
'latitude', nf90_float, dimid(3), varid(2))
3423 iret = nf90_def_var(ncid,
'longitude', nf90_float, dimid(2), varid(1))
3424 iret = nf90_def_var(ncid,
'latitude', nf90_float, dimid(3), varid(2))
3426 ELSE IF (gtype.EQ.clgtype)
THEN
3427 iret = nf90_def_var(ncid,
'longitude', nf90_float, (/ dimid(2), dimid(3)/), &
3429 iret = nf90_def_var(ncid,
'latitude', nf90_float, (/ dimid(2), dimid(3)/), &
3432 iret = nf90_def_var(ncid,
'longitude', nf90_float, dimid(2), varid(1))
3433 iret = nf90_def_var(ncid,
'latitude', nf90_float, dimid(2), varid(2))
3435 iret=nf90_put_att(ncid,varid(1),
'units',
'degree_east')
3438 IF ( .NOT. rtdl )
THEN
3440 iret=nf90_put_att(ncid,varid(1),
'long_name',
'longitude')
3441 iret=nf90_put_att(ncid,varid(1),
'standard_name',
'longitude')
3445 iret=nf90_put_att(ncid,varid(1),
'long_name',
'longitude in rotated pole grid')
3446 iret=nf90_put_att(ncid,varid(1),
'standard_name',
'grid_longitude')
3449 iret=nf90_put_att(ncid,varid(1),
'valid_min',-180.0)
3450 iret=nf90_put_att(ncid,varid(1),
'valid_max',360.)
3452 iret=nf90_put_att(ncid,varid(2),
'units',
'degree_north')
3454 IF ( .NOT. rtdl )
THEN
3456 iret=nf90_put_att(ncid,varid(2),
'long_name',
'latitude')
3457 iret=nf90_put_att(ncid,varid(2),
'standard_name',
'latitude')
3461 iret=nf90_put_att(ncid,varid(2),
'long_name',
'latitude in rotated pole grid')
3462 iret=nf90_put_att(ncid,varid(2),
'standard_name',
'grid_latitude')
3465 iret=nf90_put_att(ncid,varid(2),
'valid_min',-90.0)
3466 iret=nf90_put_att(ncid,varid(2),
'valid_max',90.)
3470 IF(smcotype .EQ. 1)
THEN
3475 iret = nf90_def_var(ncid,
'standard_longitude', nf90_float, &
3476 (/ dimid(2) /), varid(7))
3479 iret = nf90_def_var(ncid,
'standard_latitude', nf90_float, &
3480 (/ dimid(2) /), varid(8))
3489 iret = nf90_def_var(ncid,
'standard_longitude', nf90_float, &
3490 (/ dimid(2), dimid(3)/), varid(7))
3493 iret = nf90_def_var(ncid,
'standard_latitude', nf90_float, &
3494 (/ dimid(2), dimid(3)/), varid(8))
3505 iret = nf90_def_var(ncid,
'standard_longitude', nf90_float, (/ dimid(2), dimid(3)/), &
3509 iret = nf90_def_var(ncid,
'standard_latitude', nf90_float, (/ dimid(2), dimid(3)/), &
3519 iret=nf90_put_att(ncid,varid(7),
'units',
'degree_east')
3520 iret=nf90_put_att(ncid,varid(7),
'long_name',
'longitude')
3521 iret=nf90_put_att(ncid,varid(7),
'standard_name',
'longitude')
3522 iret=nf90_put_att(ncid,varid(7),
'valid_min',-180.0)
3523 iret=nf90_put_att(ncid,varid(7),
'valid_max',360.)
3526 iret=nf90_put_att(ncid,varid(8),
'units',
'degree_north')
3527 iret=nf90_put_att(ncid,varid(8),
'long_name',
'latitude')
3528 iret=nf90_put_att(ncid,varid(8),
'standard_name',
'latitude')
3529 iret=nf90_put_att(ncid,varid(8),
'valid_min',-90.0)
3530 iret=nf90_put_att(ncid,varid(8),
'valid_max',90.)
3550 IF (gtype.EQ.rlgtype)
THEN
3551 iret = nf90_def_var(ncid,
'x', nf90_float, dimid(2), varid(1))
3552 iret = nf90_def_var(ncid,
'y', nf90_float, dimid(3), varid(2))
3553 ELSE IF (gtype.EQ.clgtype)
THEN
3554 iret = nf90_def_var(ncid,
'x', nf90_float, (/ dimid(2), dimid(3)/), &
3556 iret = nf90_def_var(ncid,
'y', nf90_float, (/ dimid(2), dimid(3)/), &
3559 iret = nf90_def_var(ncid,
'x', nf90_float, dimid(2), varid(1))
3560 iret = nf90_def_var(ncid,
'y', nf90_float, dimid(2), varid(2))
3563 iret=nf90_put_att(ncid,varid(1),
'units',
'm')
3564 iret=nf90_put_att(ncid,varid(1),
'long_name',
'x')
3565 iret=nf90_put_att(ncid,varid(2),
'units',
'm')
3566 iret=nf90_put_att(ncid,varid(2),
'long_name',
'y')
3570 iret=nf90_put_att(ncid,varid(1),
'axis',
'X')
3571 iret=nf90_put_att(ncid,varid(2),
'axis',
'Y')
3572 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(1), 1, 1, deflate)
3573 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(2), 1, 1, deflate)
3578 if (extradim.EQ.1)
THEN
3579 iret = nf90_def_var(ncid,
'f', nf90_float, dimid(4), varid(10))
3580 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(10), 1, 1, deflate)
3582 iret=nf90_put_att(ncid,varid(10),
'long_name',
'wave_frequency')
3584 iret=nf90_put_att(ncid,varid(10),
'standard_name',
'wave_frequency')
3586 iret=nf90_put_att(ncid,varid(10),
'units',
's-1')
3588 iret=nf90_put_att(ncid,varid(10),
'axis',
'Hz')
3597 iret = nf90_def_var(ncid,
'time', tvartype, dimid(4+extradim), varid(3))
3599 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(3), 1, 1, deflate)
3603 iret=nf90_put_att(ncid,varid(3),
'long_name',
'time in 360 day calendar')
3605 iret=nf90_put_att(ncid,varid(3),
'long_name',
'time in 365 day calendar')
3608 iret=nf90_put_att(ncid,varid(3),
'long_name',
'time')
3611 iret=nf90_put_att(ncid,varid(3),
'standard_name',
'time')
3615 iret=nf90_put_att(ncid,varid(3),
'units', epoch)
3620 iret=nf90_put_att(ncid,varid(3),
'axis',
'T')
3622 iret=nf90_put_att(ncid,varid(3),
'calendar',trim(
caltype))
3628 iret = nf90_def_var(ncid,
'forecast_period', nf90_int, &
3629 dimid(4+extradim), varid(11))
3631 iret = nf90_put_att(ncid, varid(11),
'long_name', &
3634 iret = nf90_put_att(ncid, varid(11),
'standard_name', &
3637 iret = nf90_put_att(ncid, varid(11),
'units',
's')
3641 iret = nf90_def_var(ncid,
'forecast_reference_time', &
3642 tvartype, varid=varid(12))
3645 iret = nf90_put_att(ncid, varid(12),
'long_name', &
3646 'forecast reference time')
3649 iret = nf90_put_att(ncid, varid(12),
'standard_name', &
3650 'forecast_reference_time')
3653 iret = nf90_put_att(ncid, varid(12),
'units', epoch)
3657 iret = nf90_put_att(ncid, varid(12),
'calendar',
'gregorian')
3661 coords_attr = trim(coords_attr) //
" forecast_period forecast_reference_time"
3666 IF (gtype.EQ.ungtype)
THEN
3667 dimtri(1)=dimid(4+extradim+1)
3669 iret = nf90_def_var(ncid,
'tri', nf90_int, dimtri, varid(4))
3670 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(4), 1, 1, deflate)
3676 IF (gtype.EQ.ungtype)
THEN
3677 iret = nf90_def_var(ncid,
'MAPSTA', nf90_short,(/ dimid(2) /), varid(20))
3679 iret = nf90_def_var(ncid,
'MAPSTA', nf90_short,(/ dimid(2) , dimid(3) /), &
3682 IF (nctype.EQ.4) iret = nf90_def_var_deflate(ncid, varid(20), 1, 1, deflate)
3684 iret=nf90_put_att(ncid,varid(20),
'long_name',
'status map')
3685 iret=nf90_put_att(ncid,varid(20),
'standard_name',
'status map')
3686 iret=nf90_put_att(ncid,varid(20),
'units',
'1')
3688 iret=nf90_put_att(ncid,varid(20),
'valid_min',-32)
3690 iret=nf90_put_att(ncid,varid(20),
'valid_max',32)
3696 IF(crs_meta%N .GT. 0)
THEN
3697 iret = nf90_def_var(ncid, crs_name, nf90_char, varid=ivar)
3701 CALL write_freeform_meta_list(ncid, ivar, crs_meta, ierr)
3707 IF(fl_default_gbl_meta)
THEN
3708 iret=nf90_put_att(ncid,nf90_global,
'WAVEWATCH_III_version_number' ,trim(wwver))
3710 iret=nf90_put_att(ncid,nf90_global,
'WAVEWATCH_III_switches',trim(switches))
3713 IF (zzwnd.NE.10) iret=nf90_put_att(ncid,nf90_global,
'SIN4 namelist parameter ZWD',zzwnd)
3714 IF (aalpha.NE.0.0095) iret=nf90_put_att(ncid,nf90_global,
'SIN4 namelist parameter ALPHA0',aalpha)
3715 IF (bbeta.NE.1.43) iret=nf90_put_att(ncid,nf90_global,
'SIN4 namelist parameter BETAMAX',bbeta)
3716 IF(ssdsc(7).NE.0.3) iret=nf90_put_att(ncid,nf90_global,
'SDS4 namelist parameter WHITECAPWIDTH', ssdsc(7))
3722 IF(smcotype .EQ. 1)
THEN
3723 iret = nf90_put_att(ncid, nf90_global,
'first_lat', y0)
3725 iret = nf90_put_att(ncid, nf90_global,
'first_lon', x0)
3727 iret = nf90_put_att(ncid, nf90_global,
'base_lat_size', dlat)
3729 iret = nf90_put_att(ncid, nf90_global,
'base_lon_size', dlon)
3731 iret=nf90_put_att(ncid,nf90_global,
'SMC_grid_type',
'seapoint')
3733 ELSE IF(smcotype .EQ. 2)
THEN
3734 iret=nf90_put_att(ncid,nf90_global,
'SMC_grid_type',
'regular_regridded')
3742 CALL write_global_meta(ncid, iret)
3747 open(unit=994,
file=
'NC_globatt.inp',status=
'old',iostat=icode)
3748 IF (icode.EQ.0)
THEN
3749 DO WHILE (icode.EQ.0)
3750 read(994,
'(a)',iostat=icode) attname
3751 read(994,
'(a)',iostat=icode) attval
3752 IF (icode.EQ.0)
THEN
3753 strl=len_trim(attname)
3754 strl2=len_trim(attval)
3755 iret=nf90_put_att(ncid,nf90_global,attname(1:strl),attval(1:strl2))
3761 IF(fl_default_gbl_meta)
THEN
3762 iret=nf90_put_att(ncid,nf90_global,
'product_name' ,trim(ncfile))
3764 iret=nf90_put_att(ncid,nf90_global,
'area',trim(gname))
3787 SUBROUTINE s2grid(S, X, FLDIRN)
3819 REAL,
INTENT(INOUT) :: S(:)
3820 REAL,
INTENT(OUT) :: X(:,:)
3821 LOGICAL,
OPTIONAL,
INTENT(IN) :: FLDIRN
3827 IF(
PRESENT(fldirn)) fldr = fldirn
3831 CALL w3s2xy_smc( s, x, fldr )
3836 IF (s(isea) .NE.
undef )
THEN
3837 s(isea) = mod( 630. -
rade * s(isea) , 360. )
3843 IF(noval .NE.
undef)
WHERE(s .EQ.
undef) s = noval
3845 CALL w3s2xy ( nsea, nsea, nx+1, ny, s, mapsf, x )
3873 REAL,
INTENT(INOUT) :: U(:), V(:)
3874 REAL,
INTENT(IN),
OPTIONAL :: TOLERANCE
3880 IF(
PRESENT(tolerance)) tol = tolerance
3883 mag = sqrt(u(isea)**2 + v(isea)**2)
3884 IF(mag .GT. tol)
THEN
3885 v(isea) = mod( 630. -
rade * atan2(u(isea), v(isea)), 360. )
3913 IF (iret .NE. nf90_noerr)
THEN
3914 WRITE(
ndse,*)
' *** WAVEWATCH III ERROR IN OUNF :'
3915 WRITE(
ndse,*)
' LINE NUMBER ', iline
3916 WRITE(
ndse,*)
' NETCDF ERROR MESSAGE: '
3917 WRITE(
ndse,*) nf90_strerror(iret)