Error while adding a second set of output stations
Up to now I had 1 station output file for elevation only with 36 stations.
In Usrdef_Model.f90,
novarstsr = 1
nosetstsr = 1
nostatstsr = 36
In Usrdef_Time_Series.f90
!---varids and ranks
tsrvars%ivarid = (/iarr_zeta/)
tsrvars%nrank = 2
!---Variable indices
ivarstsr(1,1) = 1
!---File parameters
tsr2d(1)%defined = .TRUE.
!---Output attributes
tsrgpars(1)%gridded = .FALSE.
tsrgpars(1)%nostats = 36
tsrgpars(1)%tlims(1:2) = (/0,nstep/)
tsrgpars(1)%tlims(3) = 1
!---Station locations for zeta
OPEN(iunit_s, file='NoS_zeta_stations', status='old')
istat_610: DO istat=1,36
READ (iunit_s,*) tsrstatlocs(istat)%name,tsrstatlocs(istat)%xpos, tsrstatlocs(istat)%ypos
IF (master) THEN
PRINT*, 'Reading Zeta station: ', istat, tsrstatlocs(istat)%name,tsrstatlocs(istat)%xpos,&
& tsrstatlocs(istat)%ypos
ENDIF
ENDDO istat_610
CLOSE(iunit_s)
!---Store index
lstatstsr(1:36,1) = (/(l,l=1,36)/)
But now since I had a second file with 38 stations for SST, the above code should be modified. I want 2 outputs files , 1 with 36 stations for zeta and another one with 38 stations for SST. So the above code must be modified as follow
In Usrdef_Model.f90,
novarstsr = 2
nosetstsr = 2
nostatstsr = 36 + 38
In Usrdef_Time_Series.f90
!---varids and ranks
tsrvars%ivarid = (/iarr_zeta, iarr_sst/)
tsrvars%nrank = 2
!---Variable indices
ivarstsr(1,1) = 1
ivarstsr(1,2) = 2
!---File parameters
tsr2d(1)%defined = .TRUE.
tsr2d(2)%defined = .TRUE.
!---Output attributes
tsrgpars(1)%gridded = .FALSE.
tsrgpars(1)%nostats = 36
tsrgpars(1)%tlims(1:2) = (/0,nstep/)
tsrgpars(1)%tlims(3) = 1
tsrgpars(2)%gridded = .FALSE.
tsrgpars(2)%nostats = 38
tsrgpars(2)%tlims(1:2) = (/0,nstep/)
tsrgpars(2)%tlims(3) = 1
!---Station locations for zeta
OPEN(iunit_s, file='NoS_zeta_stations', status='old')
istat_610: DO istat=1,36
READ (iunit_s,*) tsrstatlocs(istat)%name,tsrstatlocs(istat)%xpos, tsrstatlocs(istat)%ypos
IF (master) THEN
PRINT*, 'Reading Zeta station: ', istat, tsrstatlocs(istat)%name,tsrstatlocs(istat)%xpos,&
& tsrstatlocs(istat)%ypos
ENDIF
ENDDO istat_610
CLOSE(iunit_s)
!7. Station locations for SST
OPEN(iunit_sst, file='NoS_SST_stations', status='old')
istat_710: DO istat=37,74
READ (iunit_sst,*) tsrstatlocs(istat)%name,tsrstatlocs(istat)%xpos, tsrstatlocs(istat)%ypos
IF (master) THEN
PRINT*, 'Reading SST station: ', istat, tsrstatlocs(istat)%name,tsrstatlocs(istat)%xpos,&
& tsrstatlocs(istat)%ypos
ENDIF
ENDDO istat_710
CLOSE(iunit_sst)
!---Store index
lstatstsr(1:36,1) = (/(l,l=1,36)/)
lstatstsr(1:38,2) = (/(l,l=37,74)/)
I know that the changes that I have added are good because I have printed in the code (Time_Series.f90) the attributes %name, %xpos & %ypos and they returned the right values.
The error that I get is not the same if I run in serial or parallel.
Serial | Parallel |
---|---|
free(): corrupted unsorted chunks | malloc(): invalid size (unsorted) |
But both type of runs are stopping in the initialization while creating the output NetCDF & writing the attributes. I have tried to use the debug mode and write some PRINT statement but it seems that I can not find the issue properly. To keep on to work, I will go for 1 unique file instead of 2.