I have a string of code that is missing two/three things that are required in order to complete the code and have it compile correctly. I was wondering if anyone would be able to help me? The code includes comments that should help out with the program. If you require more information about the program, please let me know! The code is as follows:
C/*-------------------------------------------------------------------*/
C/* MILESTONE 5 */
C/* WRITTEN BY: MAX THOMPSON */
C/* NOVEMBER 19, 2009 */
C/* CORRECTIONS: June 25, 2010 */
C/* */
C/* This program will accept four command line arguments for a */
C/* latitude and longitude value, cloud fraction total and radiation */
C/* downwelling at the Earth's surface NetCDF files. This FORTRAN90 */
C/* code will compute the correlation between the monthly averaged */
C/* cloud fraction and radiation longwave downwelling at the surface */
C/* model outputs for two seperate months. */
C/*-------------------------------------------------------------------*/
PROGRAM MileStone5
C/*-------------------------------------------------------------------*/
C/* IMPLICIT NONE states that all variables must be declared. */
C/*-------------------------------------------------------------------*/
IMPLICIT NONE
C/*-------------------------------------------------------------------*/
C/* NetCDF INCLUDE file 'netcdf.inc', so the program recongnizes */
C/* NetCDF functions. */
C/*-------------------------------------------------------------------*/
INCLUDE 'netcdf.inc'
C/*-------------------------------------------------------------------*/
C/* Declaration of all variables. */
C/*-------------------------------------------------------------------*/
INTEGER*4
1 nargs, ! Number of command line arguments
2 IARGC, ! Intrinsic function that retrieves them
3 ncrcode, ! NetCDF function/subroutine status report
4 f, ! Unit to open file with correlation values
5 g, ! Index used as unit to open dummy file
6 nvars, ! Number of NetCDF variables
7 ncid1, ! NetCDF file ID for CLT Data
8 RCODE, ! Error value, should be zero
9 ndims, ! Number of NetCDF dimensions
1 recdim, ! Record dimensions of NetCDF file
2 ngatts, ! Number of NetCDF global attributes
3 i, ! Variable used to count in arrays
4 j, ! Variable used to count in arrays
5 ncid2, ! NetCDF file ID for RLDS data
6 p, ! Variable used to count in arrays
7 q, ! Variable used to count in arrays
8 r, ! Variable used to count in arrays
9 s, ! Variable used to count in arrays
1 t, ! Variable used to count in arrays
2 u, ! Variable used to count in arrays
3 v, ! Variable used to count in arrays
4 w ! Variable used to count in arrays
REAL*4
1 lat, ! Latitude variable
2 lon ! Longitude variable
REAL*8
1 sumcrf, ! Sum of individual values multiplied together for Feb
2 sumcf, ! Sum of all CFT values for Feb
3 sumrf, ! Sum of all RLDS values for Feb
4 sumccf, ! Sum of all CFT values squared for Feb
5 sumRRF, ! Sum of all RLDS values squared for Feb
6 sumCSQF, ! Sum of all CFT values, then squared for Feb
7 sumRSQF, ! Sum of all RLDS values, then squared for Feb
8 sqrtcf, ! Square root of CFT values for Feb
9 sqrtrf, ! Square root of RLDS values for Feb
1 sumcrj, ! Sum of individual values multiplied together for July
2 sumcj, ! Sum of all CFT values for July
3 sumrj, ! Sum of all RLDS values for July
4 sumccj, ! Sum of all CFT values squared for July
5 sumrrj, ! Sum of all RLDS values squared for July
6 sumRSQJ, ! Sum of all RLDS values, then squared for July
7 sumCSQJ, ! Sum of all CFT values, then squared for July
8 sqrtcj, ! Square root for CFT values in July
9 sqrtrj, ! Square root for RLDS values in July
1 corrFEB, ! Correlation for Feb
2 corrJUL, ! Correlation for July
3 lonBNDS(384),
4 latBNDS(290)
CHARACTER(LEN=512)
1 clt_file, ! Name of clt file
2 rlds_file, ! Name of output file
3 latitude_temp, ! Temporary latitude file
4 longitude_temp ! Temporary longitue file
C/*-------------------------------------------------------------------*/
C/* Declaration of latitude and longitude values and bounds to store */
C/* values in array with specific set dimensions. */
C/*-------------------------------------------------------------------*/
INTEGER*4, DIMENSION(1) :: countlat
INTEGER*4, DIMENSION(1) :: startlat
INTEGER*4, DIMENSION(1) :: countlon
INTEGER*4, DIMENSION(1) :: startlon
INTEGER*4, DIMENSION(2) :: startbounds
INTEGER*4, DIMENSION(2) :: countbounds
C/*-------------------------------------------------------------------*/
C/* Declare all allocatable array integers used in the program. */
C/*-------------------------------------------------------------------*/
INTEGER*4, ALLOCATABLE, DIMENSION) :: VARID
INTEGER*4, ALLOCATABLE, DIMENSION) :: VARTYPE
INTEGER*4, ALLOCATABLE, DIMENSION) :: NVDIMS
INTEGER*4, ALLOCATABLE, DIMENSION) :: VDIMSTMP
INTEGER*4, ALLOCATABLE, DIMENSION, :: VDIMS
INTEGER*4, ALLOCATABLE, DIMENSION) :: NVATTS
INTEGER*4, ALLOCATABLE :: START), COUNT)
C/*-------------------------------------------------------------------*/
C/* Declaration of allocatable array character. */
C/*-------------------------------------------------------------------*/
CHARACTER(LEN=200), ALLOCATABLE, DIMENSION) :: VARNAME
C/*-------------------------------------------------------------------*/
C/* Declare all allocatable array reals used in the program. */
C/*-------------------------------------------------------------------*/
REAL*4, ALLOCATABLE :: CFTVALUES)
REAL*4, ALLOCATABLE :: RLDSVALUES)
REAL*4, ALLOCATABLE :: CFTVALUEFEB)
REAL*4, ALLOCATABLE :: CFTVALUEJULY)
REAL*4, ALLOCATABLE :: RLDSVALUEFEB)
REAL*4, ALLOCATABLE :: RLDSVALUEJULY)
REAL*4, ALLOCATABLE :: difJUL)
REAL*4, ALLOCATABLE :: difFEB)
REAL*8, ALLOCATABLE :: LONValues)
REAL*8, ALLOCATABLE :: LATValues)
f = 10
g = 11
C/*-------------------------------------------------------------------*/
C/* Use the IARGC function to retrieve the number of command line */
C/* arguments and stores them in the integer variable nargs. */
C/*-------------------------------------------------------------------*/
nargs = IARGC()
C/*-------------------------------------------------------------------*/
C/* Be sure there are four command line arguments being entered. */
C/*-------------------------------------------------------------------*/
IF (nargs .ne. 4) THEN
WRITE(*,*) 'You must enter 4 command line arguments:'
WRITE(*,*) ' 1) A latitude value'
WRITE(*,*) ' 2) A longitude value'
WRITE(*,*) ' 3) Enter location of cloud fraction total file'
WRITE(*,*) ' 4) Enter location of radiation longwave file'
STOP
END IF
C/*-------------------------------------------------------------------*/
C/* Retrieves the latitude value that is entered by the user and */
C/* converts that value into a number, and the NetCDF files. */
C/*-------------------------------------------------------------------*/
CALL GETARG(1, latitude_temp)
CALL GETARG(2, longitude_temp)
CALL GETARG(3, clt_file)
CALL GETARG(4, rlds_file)
C/*-------------------------------------------------------------------*/
C/* Take latitude and longitude and write them into a "dummy" file as */
C/* a character, then read them back into the program as a real. */
C/*-------------------------------------------------------------------*/
OPEN(UNIT=g, File = 'temp.data')
WRITE(g, "(A6)") latitude_temp
CLOSE(g)
OPEN(UNIT=g, File = 'temp.data')
READ(g, "(F6.2)") lat
CLOSE(g)
OPEN(UNIT=g, File = 'temp.data')
WRITE(g, "(A6)") longitude_temp
CLOSE(g)
OPEN(UNIT=g, File = 'temp.data')
READ(g, "(F6.2)") lon
CLOSE(g)
C/*-------------------------------------------------------------------*/
C/* If the longitude value is less than zero, then add 360. Otherwise,*/
C/* do nothing to the value. */
C/*-------------------------------------------------------------------*/
IF (lon .le. 0) THEN
lon = 360 + lon
END IF
C/*-------------------------------------------------------------------*/
C/* Enter the values as defined above. */
C/*-------------------------------------------------------------------*/
nvars = 7
ndims = 4
ngatts = 13
recdim = 3
C/*-------------------------------------------------------------------*/
C/* Begin allocating the arrays with the proper number and type. */
C/*-------------------------------------------------------------------*/
ALLOCATE(VARID(nvars))
ALLOCATE(VARNAME(nvars))
ALLOCATE(VARTYPE(nvars))
ALLOCATE(VDIMS(nvars,ndims))
ALLOCATE(NVDIMS(nvars))
ALLOCATE(NVATTS(nvars))
ALLOCATE(VDIMSTMP(ndims))
ALLOCATE(START(3))
ALLOCATE(COUNT(3))
C/*-------------------------------------------------------------------*/
C/* Allocate the number of CLT and RLDS values to 1680 becase there */
C/* are that many times for each lat and lon combination. We must */
C/* also allocate space for the number of values of lat and lon, */
C/* respectively at 145 and 192. */
C/*-------------------------------------------------------------------*/
ALLOCATE(LATValues(145))
ALLOCATE(LONValues(192))
ALLOCATE(CFTVALUES(1680))
ALLOCATE(RLDSVALUES(1680))
C/*-------------------------------------------------------------------*/
C/* Set the START and COUNT for the bounds to get lat and lon. */
C/*-------------------------------------------------------------------*/
startbounds(1) = 1
countbounds(1) = 2
startbounds(2) = 1
countbounds(2) = 192
ncid1 = NCOPN(clt_file, NCNOWRIT, ncrcode)
CALL NCVGT(ncid1,2,startbounds,countbounds,lonBNDS,ncrcode)
CALL NCCLOS(ncid1, ncrcode)
startbounds(1) = 1
countbounds(1) = 2
startbounds(2) = 1
countbounds(2) = 145
ncid1 = NCOPN(clt_file, NCNOWRIT, ncrcode)
CALL NCVGT(ncid1,4,startbounds,countbounds,latBNDS,ncrcode)
CALL NCCLOS(ncid1, ncrcode)
startlon(1) = 1
countlon(1) = 192
startlat(1) = 1
countlat(1) = 145
ncid1 = NCOPN(clt_file, NCNOWRIT, ncrcode)
CALL NCVGT(ncid1, 3, startlat, countlat, LATValues, ncrcode)
CALL NCVGT(ncid1, 1, startlon, countlon, LONValues, ncrcode)
CALL NCCLOS(ncid1, ncrcode)
C/*-------------------------------------------------------------------*/
C/* Determine the bound to sue for lat and lon. If the value given is */
C/* between the set bounds, adjust lon and lat to be the mean value */
C/* of the lower and upper bound. */
C/*-------------------------------------------------------------------*/
DO u = 1, 384, 1
IF((lon .ge. lonBNDS(2*u-1)) .and. (lon .le. lonBNDS(2*u))) THEN
s = u
END IF
END DO
DO u = 1, 290, 1
IF((lat .ge. latBNDS(2*u-1)) .and. (lat .le. latBNDS(2*u))) THEN
t = u
END IF
END DO
C/*-------------------------------------------------------------------*/
C/* Set START and COUNT with indicies found above and open each file */
C/* to get the values for CFT and RLDS out of their respective files. */
C/* After each is opened and values are retrieved, close with NetCDF */
C/* function NCCLOS. */
C/*-------------------------------------------------------------------*/
START(1) = s
COUNT(1) = 1
START(2) = t
COUNT(2) = 1
START(3) = 1
COUNT(3) = 1680
ncid1 = NCOPN(clt_file, NCNOWRIT, ncrcode)
CALL NCVGT(ncid1,7,START,COUNT,CFTVALUES,ncrcode)
CALL NCCLOS(ncid1, ncrcode)
ncid2 = NCOPN(rlds_file, NCNOWRIT, ncrcode)
CALL NCVGT(ncid2,7,START,COUNT,RLDSVALUES,ncrcode)
CALL NCCLOS(ncid2, ncrcode)
C/*-------------------------------------------------------------------*/
C/* Allocate all values for specific month values to 140 because */
C/* there are that many years in the NetCDF file for CLT and RLDS. */
C/*-------------------------------------------------------------------*/
ALLOCATE(CFTVALUEFEB(140))
ALLOCATE(CFTVALUEJULY(140))
ALLOCATE(RLDSVALUEFEB(140))
ALLOCATE(RLDSVALUEJULY(140))
ALLOCATE(difFEB(140))
ALLOCATE(difJUL(140))
C/*-------------------------------------------------------------------*/
C/* Use a DO loop to sort through the CLT and RLDS values to only get */
C/* values for Feb. Then solve for all parts for the correlation */
C/* equation, as defined above. This uses v = v+1 to count through */
C/* values to ensure that only values desired are taken out. */
C/*-------------------------------------------------------------------*/
v = 1
DO p = 2, 1680, 12
CFTVALUEFEB(v) = CFTVALUES(p)
RLDSVALUEFEB(v) = RLDSVALUES(p)
sumcf = sumcf + CFTVALUEFEB(v)
sumrf = sumrf + RLDSVALUEFEB(v)
sumcrf = sumcrf + (CFTVALUEFEB(v)*RLDSVALUEFEB(v))
sumccf = sumccf + (CFTVALUEFEB(v)*CFTVALUEFEB(v))
sumrrf = sumrrf + (RLDSVALUEFEB(v)*RLDSVALUEFEB(v))
v = v + 1
END DO
sumCSQF = sumcf**2
sumRSQF = sumrf**2
sqrtcf = SQRT((140*sumccf) - sumCSQF)
sqrtrf = SQRT((140*sumrrf) - sumRSQF)
corrFEB = ((140*sumcrf) - (sumcf*sumrf)) / (sqrtcf*sqrtrf)
C/*-------------------------------------------------------------------*/
C/* Use a DO loop to sort through the CLT and RLDS values to only get */
C/* values for July. Then repeat as above to solve for July */
C/* correlation. */
C/*-------------------------------------------------------------------*/
w = 1
DO p = 7, 1680, 12
CFTVALUEJULY(w) = CFTVALUES(p)
RLDSVALUEJULY(w) = RLDSVALUES(p)
sumcj = sumcj + CFTVALUEJULY(w)
sumrj = sumrj + RLDSVALUEJULY(w)
sumcrj = sumcrj + (CFTVALUEJULY(w)*RLDSVALUEJULY(w))
sumccj = sumccj + (CFTVALUEJULY(w)*CFTVALUEJULY(w))
sumrrj = sumrrj + (RLDSVALUEJULY(w)*RLDSVALUEJULY(w))
w = w + 1
END DO
sumCSQF = sumcj**2
sumRSQJ = sumrj**2
sqrtcj = SQRT((140*sumccj) - sumCSQF)
sqrtrj = SQRT((140*sumrrj) - sumRSQJ)
corrJUL = ((140*sumcrj) - (sumcj*sumrj))/(sqrtcj*sqrtrj)
C/*-------------------------------------------------------------------*/
C/* Open the final file that will have the destination of cloud */
C/* fraction total and radiation longwave downwelling at the surface */
C/* in addition to the converted lat and lon. Finally, print the */
C/* correlation for both months to the file. Once all the values have */
C/* been written, close the file. */
C/*-------------------------------------------------------------------*/
OPEN(UNIT=f, FILE='MileStone5.ThompsonMax.Correlation.data')
WRITE(f,"(A33)") 'Cloud Fraction Total (cft) File:'
WRITE(f,*)
WRITE(f,*) clt_file
WRITE(f,*)
WRITE(f,"(A60)") 'Radiation Longwave Downwelling at the Surface
&(rlds) File:'
WRITE(f,*)
WRITE(f,*) rlds_file
WRITE(f,*)
WRITE(f,"(A25,F6.2,A1,A11,F7.3,A1)")'State College (Latitude: '
1,lat,';','Longitude: ',lon,')'
WRITE(f,*)
WRITE(f,"(A88)") 'Cloud Fraction and Radiation Downwelling Long
1wave at Surface Correlation (February): '
WRITE(f,"(F6.2)") corrFEB
WRITE(f,*)
WRITE(f,"(A84)") 'Cloud Fraction and Radiation Downwelling Long
1wave at Surface Correlation (July): '
WRITE(f,"(F6.2)") corrJUL
CLOSE(f)
END
C/*-------------------------------------------------------------------*/
C/* MILESTONE 5 */
C/* WRITTEN BY: MAX THOMPSON */
C/* NOVEMBER 19, 2009 */
C/* CORRECTIONS: June 25, 2010 */
C/* */
C/* This program will accept four command line arguments for a */
C/* latitude and longitude value, cloud fraction total and radiation */
C/* downwelling at the Earth's surface NetCDF files. This FORTRAN90 */
C/* code will compute the correlation between the monthly averaged */
C/* cloud fraction and radiation longwave downwelling at the surface */
C/* model outputs for two seperate months. */
C/*-------------------------------------------------------------------*/
PROGRAM MileStone5
C/*-------------------------------------------------------------------*/
C/* IMPLICIT NONE states that all variables must be declared. */
C/*-------------------------------------------------------------------*/
IMPLICIT NONE
C/*-------------------------------------------------------------------*/
C/* NetCDF INCLUDE file 'netcdf.inc', so the program recongnizes */
C/* NetCDF functions. */
C/*-------------------------------------------------------------------*/
INCLUDE 'netcdf.inc'
C/*-------------------------------------------------------------------*/
C/* Declaration of all variables. */
C/*-------------------------------------------------------------------*/
INTEGER*4
1 nargs, ! Number of command line arguments
2 IARGC, ! Intrinsic function that retrieves them
3 ncrcode, ! NetCDF function/subroutine status report
4 f, ! Unit to open file with correlation values
5 g, ! Index used as unit to open dummy file
6 nvars, ! Number of NetCDF variables
7 ncid1, ! NetCDF file ID for CLT Data
8 RCODE, ! Error value, should be zero
9 ndims, ! Number of NetCDF dimensions
1 recdim, ! Record dimensions of NetCDF file
2 ngatts, ! Number of NetCDF global attributes
3 i, ! Variable used to count in arrays
4 j, ! Variable used to count in arrays
5 ncid2, ! NetCDF file ID for RLDS data
6 p, ! Variable used to count in arrays
7 q, ! Variable used to count in arrays
8 r, ! Variable used to count in arrays
9 s, ! Variable used to count in arrays
1 t, ! Variable used to count in arrays
2 u, ! Variable used to count in arrays
3 v, ! Variable used to count in arrays
4 w ! Variable used to count in arrays
REAL*4
1 lat, ! Latitude variable
2 lon ! Longitude variable
REAL*8
1 sumcrf, ! Sum of individual values multiplied together for Feb
2 sumcf, ! Sum of all CFT values for Feb
3 sumrf, ! Sum of all RLDS values for Feb
4 sumccf, ! Sum of all CFT values squared for Feb
5 sumRRF, ! Sum of all RLDS values squared for Feb
6 sumCSQF, ! Sum of all CFT values, then squared for Feb
7 sumRSQF, ! Sum of all RLDS values, then squared for Feb
8 sqrtcf, ! Square root of CFT values for Feb
9 sqrtrf, ! Square root of RLDS values for Feb
1 sumcrj, ! Sum of individual values multiplied together for July
2 sumcj, ! Sum of all CFT values for July
3 sumrj, ! Sum of all RLDS values for July
4 sumccj, ! Sum of all CFT values squared for July
5 sumrrj, ! Sum of all RLDS values squared for July
6 sumRSQJ, ! Sum of all RLDS values, then squared for July
7 sumCSQJ, ! Sum of all CFT values, then squared for July
8 sqrtcj, ! Square root for CFT values in July
9 sqrtrj, ! Square root for RLDS values in July
1 corrFEB, ! Correlation for Feb
2 corrJUL, ! Correlation for July
3 lonBNDS(384),
4 latBNDS(290)
CHARACTER(LEN=512)
1 clt_file, ! Name of clt file
2 rlds_file, ! Name of output file
3 latitude_temp, ! Temporary latitude file
4 longitude_temp ! Temporary longitue file
C/*-------------------------------------------------------------------*/
C/* Declaration of latitude and longitude values and bounds to store */
C/* values in array with specific set dimensions. */
C/*-------------------------------------------------------------------*/
INTEGER*4, DIMENSION(1) :: countlat
INTEGER*4, DIMENSION(1) :: startlat
INTEGER*4, DIMENSION(1) :: countlon
INTEGER*4, DIMENSION(1) :: startlon
INTEGER*4, DIMENSION(2) :: startbounds
INTEGER*4, DIMENSION(2) :: countbounds
C/*-------------------------------------------------------------------*/
C/* Declare all allocatable array integers used in the program. */
C/*-------------------------------------------------------------------*/
INTEGER*4, ALLOCATABLE, DIMENSION) :: VARID
INTEGER*4, ALLOCATABLE, DIMENSION) :: VARTYPE
INTEGER*4, ALLOCATABLE, DIMENSION) :: NVDIMS
INTEGER*4, ALLOCATABLE, DIMENSION) :: VDIMSTMP
INTEGER*4, ALLOCATABLE, DIMENSION, :: VDIMS
INTEGER*4, ALLOCATABLE, DIMENSION) :: NVATTS
INTEGER*4, ALLOCATABLE :: START), COUNT)
C/*-------------------------------------------------------------------*/
C/* Declaration of allocatable array character. */
C/*-------------------------------------------------------------------*/
CHARACTER(LEN=200), ALLOCATABLE, DIMENSION) :: VARNAME
C/*-------------------------------------------------------------------*/
C/* Declare all allocatable array reals used in the program. */
C/*-------------------------------------------------------------------*/
REAL*4, ALLOCATABLE :: CFTVALUES)
REAL*4, ALLOCATABLE :: RLDSVALUES)
REAL*4, ALLOCATABLE :: CFTVALUEFEB)
REAL*4, ALLOCATABLE :: CFTVALUEJULY)
REAL*4, ALLOCATABLE :: RLDSVALUEFEB)
REAL*4, ALLOCATABLE :: RLDSVALUEJULY)
REAL*4, ALLOCATABLE :: difJUL)
REAL*4, ALLOCATABLE :: difFEB)
REAL*8, ALLOCATABLE :: LONValues)
REAL*8, ALLOCATABLE :: LATValues)
f = 10
g = 11
C/*-------------------------------------------------------------------*/
C/* Use the IARGC function to retrieve the number of command line */
C/* arguments and stores them in the integer variable nargs. */
C/*-------------------------------------------------------------------*/
nargs = IARGC()
C/*-------------------------------------------------------------------*/
C/* Be sure there are four command line arguments being entered. */
C/*-------------------------------------------------------------------*/
IF (nargs .ne. 4) THEN
WRITE(*,*) 'You must enter 4 command line arguments:'
WRITE(*,*) ' 1) A latitude value'
WRITE(*,*) ' 2) A longitude value'
WRITE(*,*) ' 3) Enter location of cloud fraction total file'
WRITE(*,*) ' 4) Enter location of radiation longwave file'
STOP
END IF
C/*-------------------------------------------------------------------*/
C/* Retrieves the latitude value that is entered by the user and */
C/* converts that value into a number, and the NetCDF files. */
C/*-------------------------------------------------------------------*/
CALL GETARG(1, latitude_temp)
CALL GETARG(2, longitude_temp)
CALL GETARG(3, clt_file)
CALL GETARG(4, rlds_file)
C/*-------------------------------------------------------------------*/
C/* Take latitude and longitude and write them into a "dummy" file as */
C/* a character, then read them back into the program as a real. */
C/*-------------------------------------------------------------------*/
OPEN(UNIT=g, File = 'temp.data')
WRITE(g, "(A6)") latitude_temp
CLOSE(g)
OPEN(UNIT=g, File = 'temp.data')
READ(g, "(F6.2)") lat
CLOSE(g)
OPEN(UNIT=g, File = 'temp.data')
WRITE(g, "(A6)") longitude_temp
CLOSE(g)
OPEN(UNIT=g, File = 'temp.data')
READ(g, "(F6.2)") lon
CLOSE(g)
C/*-------------------------------------------------------------------*/
C/* If the longitude value is less than zero, then add 360. Otherwise,*/
C/* do nothing to the value. */
C/*-------------------------------------------------------------------*/
IF (lon .le. 0) THEN
lon = 360 + lon
END IF
C/*-------------------------------------------------------------------*/
C/* Enter the values as defined above. */
C/*-------------------------------------------------------------------*/
nvars = 7
ndims = 4
ngatts = 13
recdim = 3
C/*-------------------------------------------------------------------*/
C/* Begin allocating the arrays with the proper number and type. */
C/*-------------------------------------------------------------------*/
ALLOCATE(VARID(nvars))
ALLOCATE(VARNAME(nvars))
ALLOCATE(VARTYPE(nvars))
ALLOCATE(VDIMS(nvars,ndims))
ALLOCATE(NVDIMS(nvars))
ALLOCATE(NVATTS(nvars))
ALLOCATE(VDIMSTMP(ndims))
ALLOCATE(START(3))
ALLOCATE(COUNT(3))
C/*-------------------------------------------------------------------*/
C/* Allocate the number of CLT and RLDS values to 1680 becase there */
C/* are that many times for each lat and lon combination. We must */
C/* also allocate space for the number of values of lat and lon, */
C/* respectively at 145 and 192. */
C/*-------------------------------------------------------------------*/
ALLOCATE(LATValues(145))
ALLOCATE(LONValues(192))
ALLOCATE(CFTVALUES(1680))
ALLOCATE(RLDSVALUES(1680))
C/*-------------------------------------------------------------------*/
C/* Set the START and COUNT for the bounds to get lat and lon. */
C/*-------------------------------------------------------------------*/
startbounds(1) = 1
countbounds(1) = 2
startbounds(2) = 1
countbounds(2) = 192
ncid1 = NCOPN(clt_file, NCNOWRIT, ncrcode)
CALL NCVGT(ncid1,2,startbounds,countbounds,lonBNDS,ncrcode)
CALL NCCLOS(ncid1, ncrcode)
startbounds(1) = 1
countbounds(1) = 2
startbounds(2) = 1
countbounds(2) = 145
ncid1 = NCOPN(clt_file, NCNOWRIT, ncrcode)
CALL NCVGT(ncid1,4,startbounds,countbounds,latBNDS,ncrcode)
CALL NCCLOS(ncid1, ncrcode)
startlon(1) = 1
countlon(1) = 192
startlat(1) = 1
countlat(1) = 145
ncid1 = NCOPN(clt_file, NCNOWRIT, ncrcode)
CALL NCVGT(ncid1, 3, startlat, countlat, LATValues, ncrcode)
CALL NCVGT(ncid1, 1, startlon, countlon, LONValues, ncrcode)
CALL NCCLOS(ncid1, ncrcode)
C/*-------------------------------------------------------------------*/
C/* Determine the bound to sue for lat and lon. If the value given is */
C/* between the set bounds, adjust lon and lat to be the mean value */
C/* of the lower and upper bound. */
C/*-------------------------------------------------------------------*/
DO u = 1, 384, 1
IF((lon .ge. lonBNDS(2*u-1)) .and. (lon .le. lonBNDS(2*u))) THEN
s = u
END IF
END DO
DO u = 1, 290, 1
IF((lat .ge. latBNDS(2*u-1)) .and. (lat .le. latBNDS(2*u))) THEN
t = u
END IF
END DO
C/*-------------------------------------------------------------------*/
C/* Set START and COUNT with indicies found above and open each file */
C/* to get the values for CFT and RLDS out of their respective files. */
C/* After each is opened and values are retrieved, close with NetCDF */
C/* function NCCLOS. */
C/*-------------------------------------------------------------------*/
START(1) = s
COUNT(1) = 1
START(2) = t
COUNT(2) = 1
START(3) = 1
COUNT(3) = 1680
ncid1 = NCOPN(clt_file, NCNOWRIT, ncrcode)
CALL NCVGT(ncid1,7,START,COUNT,CFTVALUES,ncrcode)
CALL NCCLOS(ncid1, ncrcode)
ncid2 = NCOPN(rlds_file, NCNOWRIT, ncrcode)
CALL NCVGT(ncid2,7,START,COUNT,RLDSVALUES,ncrcode)
CALL NCCLOS(ncid2, ncrcode)
C/*-------------------------------------------------------------------*/
C/* Allocate all values for specific month values to 140 because */
C/* there are that many years in the NetCDF file for CLT and RLDS. */
C/*-------------------------------------------------------------------*/
ALLOCATE(CFTVALUEFEB(140))
ALLOCATE(CFTVALUEJULY(140))
ALLOCATE(RLDSVALUEFEB(140))
ALLOCATE(RLDSVALUEJULY(140))
ALLOCATE(difFEB(140))
ALLOCATE(difJUL(140))
C/*-------------------------------------------------------------------*/
C/* Use a DO loop to sort through the CLT and RLDS values to only get */
C/* values for Feb. Then solve for all parts for the correlation */
C/* equation, as defined above. This uses v = v+1 to count through */
C/* values to ensure that only values desired are taken out. */
C/*-------------------------------------------------------------------*/
v = 1
DO p = 2, 1680, 12
CFTVALUEFEB(v) = CFTVALUES(p)
RLDSVALUEFEB(v) = RLDSVALUES(p)
sumcf = sumcf + CFTVALUEFEB(v)
sumrf = sumrf + RLDSVALUEFEB(v)
sumcrf = sumcrf + (CFTVALUEFEB(v)*RLDSVALUEFEB(v))
sumccf = sumccf + (CFTVALUEFEB(v)*CFTVALUEFEB(v))
sumrrf = sumrrf + (RLDSVALUEFEB(v)*RLDSVALUEFEB(v))
v = v + 1
END DO
sumCSQF = sumcf**2
sumRSQF = sumrf**2
sqrtcf = SQRT((140*sumccf) - sumCSQF)
sqrtrf = SQRT((140*sumrrf) - sumRSQF)
corrFEB = ((140*sumcrf) - (sumcf*sumrf)) / (sqrtcf*sqrtrf)
C/*-------------------------------------------------------------------*/
C/* Use a DO loop to sort through the CLT and RLDS values to only get */
C/* values for July. Then repeat as above to solve for July */
C/* correlation. */
C/*-------------------------------------------------------------------*/
w = 1
DO p = 7, 1680, 12
CFTVALUEJULY(w) = CFTVALUES(p)
RLDSVALUEJULY(w) = RLDSVALUES(p)
sumcj = sumcj + CFTVALUEJULY(w)
sumrj = sumrj + RLDSVALUEJULY(w)
sumcrj = sumcrj + (CFTVALUEJULY(w)*RLDSVALUEJULY(w))
sumccj = sumccj + (CFTVALUEJULY(w)*CFTVALUEJULY(w))
sumrrj = sumrrj + (RLDSVALUEJULY(w)*RLDSVALUEJULY(w))
w = w + 1
END DO
sumCSQF = sumcj**2
sumRSQJ = sumrj**2
sqrtcj = SQRT((140*sumccj) - sumCSQF)
sqrtrj = SQRT((140*sumrrj) - sumRSQJ)
corrJUL = ((140*sumcrj) - (sumcj*sumrj))/(sqrtcj*sqrtrj)
C/*-------------------------------------------------------------------*/
C/* Open the final file that will have the destination of cloud */
C/* fraction total and radiation longwave downwelling at the surface */
C/* in addition to the converted lat and lon. Finally, print the */
C/* correlation for both months to the file. Once all the values have */
C/* been written, close the file. */
C/*-------------------------------------------------------------------*/
OPEN(UNIT=f, FILE='MileStone5.ThompsonMax.Correlation.data')
WRITE(f,"(A33)") 'Cloud Fraction Total (cft) File:'
WRITE(f,*)
WRITE(f,*) clt_file
WRITE(f,*)
WRITE(f,"(A60)") 'Radiation Longwave Downwelling at the Surface
&(rlds) File:'
WRITE(f,*)
WRITE(f,*) rlds_file
WRITE(f,*)
WRITE(f,"(A25,F6.2,A1,A11,F7.3,A1)")'State College (Latitude: '
1,lat,';','Longitude: ',lon,')'
WRITE(f,*)
WRITE(f,"(A88)") 'Cloud Fraction and Radiation Downwelling Long
1wave at Surface Correlation (February): '
WRITE(f,"(F6.2)") corrFEB
WRITE(f,*)
WRITE(f,"(A84)") 'Cloud Fraction and Radiation Downwelling Long
1wave at Surface Correlation (July): '
WRITE(f,"(F6.2)") corrJUL
CLOSE(f)
END